iChatBridge.h
author Jens Alfke <jens@mooseyard.com>
Sun May 10 18:57:43 2009 -0700 (2009-05-10)
changeset 29 8874aff14cc9
permissions -rw-r--r--
* Added kv*Set utility functions for handling KV grunge when mutating an NSSet property.
* Change CFMakeCollectable to NSMakeCollectable.
     1 /*
     2  * iChat.h
     3  */
     4 
     5 #import <AppKit/AppKit.h>
     6 #import <ScriptingBridge/ScriptingBridge.h>
     7 
     8 
     9 @class iChatItem, iChatApplication, iChatColor, iChatDocument, iChatWindow, iChatRichText, iChatCharacter, iChatParagraph, iChatWord, iChatAttributeRun, iChatAttachment, iChatApplication, iChatBuddy, iChatService, iChatChat, iChatTextChat, iChatAudioChat, iChatVideoChat, iChatFileTransfer;
    10 
    11 typedef enum {
    12 	iChatSaveOptionsYes = 'yes ' /* Save the file. */,
    13 	iChatSaveOptionsNo = 'no  ' /* Do not save the file. */,
    14 	iChatSaveOptionsAsk = 'ask ' /* Ask the user whether or not to save the file. */
    15 } iChatSaveOptions;
    16 
    17 typedef enum {
    18 	iChatInviteTypeAudioInvitation = 'acon',
    19 	iChatInviteTypeTextChatInvitation = 'tcon',
    20 	iChatInviteTypeVideoInvitation = 'vcon'
    21 } iChatInviteType;
    22 
    23 typedef enum {
    24 	iChatAccountStatusAvailable = 'aval',
    25 	iChatAccountStatusAway = 'away',
    26 	iChatAccountStatusOffline = 'offl',
    27 	iChatAccountStatusInvisible = 'invs',
    28 	iChatAccountStatusIdle = 'idle',
    29 	iChatAccountStatusUnknown = 'unkn'
    30 } iChatAccountStatus;
    31 
    32 typedef enum {
    33 	iChatMyStatusAway = 'away',
    34 	iChatMyStatusAvailable = 'aval',
    35 	iChatMyStatusOffline = 'offl',
    36 	iChatMyStatusInvisible = 'invs'
    37 } iChatMyStatus;
    38 
    39 typedef enum {
    40 	iChatConnectionStatusDisconnecting = 'dcng',
    41 	iChatConnectionStatusConnected = 'conn',
    42 	iChatConnectionStatusConnecting = 'cong',
    43 	iChatConnectionStatusDisconnected = 'dcon'
    44 } iChatConnectionStatus;
    45 
    46 typedef enum {
    47 	iChatCapabilitiesVideoChat = 'vcon',
    48 	iChatCapabilitiesAudioChat = 'acon',
    49 	iChatCapabilitiesMultipersonVideo = 'mwvc',
    50 	iChatCapabilitiesMultipersonAudio = 'mwac'
    51 } iChatCapabilities;
    52 
    53 typedef enum {
    54 	iChatScreenSharingNone = 'ssns',
    55 	iChatScreenSharingLocalScreen = 'ssls',
    56 	iChatScreenSharingRemoteScreen = 'ssrs'
    57 } iChatScreenSharing;
    58 
    59 typedef enum {
    60 	iChatServiceTypeAIM = 'saim',
    61 	iChatServiceTypeBonjour = 'ssub',
    62 	iChatServiceTypeJabber = 'sjab'
    63 } iChatServiceType;
    64 
    65 typedef enum {
    66 	iChatDirectionIncoming = 'FTic',
    67 	iChatDirectionOutgoing = 'FTog'
    68 } iChatDirection;
    69 
    70 typedef enum {
    71 	iChatTransferStatusPreparing = 'FTsp',
    72 	iChatTransferStatusWaiting = 'FTsw',
    73 	iChatTransferStatusTransferring = 'FTsg',
    74 	iChatTransferStatusFinalizing = 'FTsz',
    75 	iChatTransferStatusFinished = 'FTsf',
    76 	iChatTransferStatusFailed = 'FTse'
    77 } iChatTransferStatus;
    78 
    79 typedef enum {
    80 	iChatAvTypeAudio = 'ICAa',
    81 	iChatAvTypeVideo = 'ICAv'
    82 } iChatAvType;
    83 
    84 typedef enum {
    85 	iChatChatTypeInstantMessage = 'ICim',
    86 	iChatChatTypeDirectInstantMessage = 'ICdi',
    87 	iChatChatTypeChatRoom = 'ICcr'
    88 } iChatChatType;
    89 
    90 typedef enum {
    91 	iChatJoinStateNotJoined = 'ICJc',
    92 	iChatJoinStateJoining = 'ICJg',
    93 	iChatJoinStateJoined = 'ICJj'
    94 } iChatJoinState;
    95 
    96 typedef enum {
    97 	iChatAvConnectionStatusInvited = 'ICAi',
    98 	iChatAvConnectionStatusWaiting = 'ICAw',
    99 	iChatAvConnectionStatusConnecting = 'ICAx',
   100 	iChatAvConnectionStatusConnected = 'ICAc',
   101 	iChatAvConnectionStatusEnded = 'ICAn'
   102 } iChatAvConnectionStatus;
   103 
   104 
   105 
   106 /*
   107  * Standard Suite
   108  */
   109 
   110 // A scriptable object.
   111 @interface iChatItem : SBObject
   112 
   113 @property (copy) NSDictionary *properties;  // All of the object's properties.
   114 
   115 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   116 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   117 - (void) delete;  // Delete an object.
   118 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   119 - (BOOL) exists;  // Verify if an object exists.
   120 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   121 
   122 @end
   123 
   124 // The application's top-level scripting object.
   125 @interface iChatApplication : SBApplication
   126 
   127 - (SBElementArray *) documents;
   128 - (SBElementArray *) windows;
   129 
   130 @property (copy, readonly) NSString *name;  // The name of the application.
   131 @property (readonly) BOOL frontmost;  // Is this the frontmost (active) application?
   132 @property (copy, readonly) NSString *version;  // The version of the application.
   133 
   134 - (void) open:(NSArray *)x;  // Open a document.
   135 - (void) print:(NSURL *)x;  // Print an object.
   136 - (void) quitSaving:(iChatSaveOptions)saving;  // Quit the application.
   137 - (void) invite:(NSArray *)x to:(id)to withMessage:(NSString *)withMessage;  // Invites a buddy to join an existing chat.
   138 - (void) logIn;  // Log in to the specified service, or all services if none is specified. If the account password is not in the keychain the user will be prompted to enter one.
   139 - (void) logOut;  // Logs out of a service, or all services if none is specified.
   140 - (void) send:(id)x to:(id)to;  // Sends a message or file to a buddy or to a chat.
   141 - (void) storeRecentPicture;  // Stores the currently set buddy picture into your recent pictures.
   142 - (void) showChatChooserFor:(iChatBuddy *)for_;  // displays a dialog in iChat to start a new chat with the specified buddy
   143 
   144 @end
   145 
   146 // A color.
   147 @interface iChatColor : SBObject
   148 
   149 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   150 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   151 - (void) delete;  // Delete an object.
   152 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   153 - (BOOL) exists;  // Verify if an object exists.
   154 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   155 
   156 @end
   157 
   158 // An iChat document.
   159 @interface iChatDocument : SBObject
   160 
   161 @property (copy, readonly) NSString *name;  // The document's name.
   162 @property (readonly) BOOL modified;  // Has the document been modified since the last save?
   163 @property (copy, readonly) NSURL *file;  // The document's location on disk.
   164 
   165 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   166 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   167 - (void) delete;  // Delete an object.
   168 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   169 - (BOOL) exists;  // Verify if an object exists.
   170 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   171 
   172 @end
   173 
   174 // A window.
   175 @interface iChatWindow : SBObject
   176 
   177 @property (copy, readonly) NSString *name;  // The full title of the window.
   178 - (NSInteger) id;  // The unique identifier of the window.
   179 @property NSInteger index;  // The index of the window, ordered front to back.
   180 @property NSRect bounds;  // The bounding rectangle of the window.
   181 @property (readonly) BOOL closeable;  // Whether the window has a close box.
   182 @property (readonly) BOOL minimizable;  // Whether the window can be minimized.
   183 @property BOOL minimized;  // Whether the window is currently minimized.
   184 @property (readonly) BOOL resizable;  // Whether the window can be resized.
   185 @property BOOL visible;  // Whether the window is currently visible.
   186 @property (readonly) BOOL zoomable;  // Whether the window can be zoomed.
   187 @property BOOL zoomed;  // Whether the window is currently zoomed.
   188 @property (copy, readonly) iChatDocument *document;  // The document whose contents are being displayed in the window.
   189 
   190 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   191 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   192 - (void) delete;  // Delete an object.
   193 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   194 - (BOOL) exists;  // Verify if an object exists.
   195 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   196 
   197 @end
   198 
   199 
   200 
   201 /*
   202  * Text Suite
   203  */
   204 
   205 // Rich (styled) text
   206 @interface iChatRichText : SBObject
   207 
   208 - (SBElementArray *) characters;
   209 - (SBElementArray *) paragraphs;
   210 - (SBElementArray *) words;
   211 - (SBElementArray *) attributeRuns;
   212 - (SBElementArray *) attachments;
   213 
   214 @property (copy) NSColor *color;  // The color of the first character.
   215 @property (copy) NSString *font;  // The name of the font of the first character.
   216 @property double size;  // The size in points of the first character.
   217 
   218 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   219 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   220 - (void) delete;  // Delete an object.
   221 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   222 - (BOOL) exists;  // Verify if an object exists.
   223 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   224 
   225 @end
   226 
   227 // This subdivides the text into characters.
   228 @interface iChatCharacter : SBObject
   229 
   230 - (SBElementArray *) characters;
   231 - (SBElementArray *) paragraphs;
   232 - (SBElementArray *) words;
   233 - (SBElementArray *) attributeRuns;
   234 - (SBElementArray *) attachments;
   235 
   236 @property (copy) NSColor *color;  // The color of the first character.
   237 @property (copy) NSString *font;  // The name of the font of the first character.
   238 @property NSInteger size;  // The size in points of the first character.
   239 
   240 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   241 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   242 - (void) delete;  // Delete an object.
   243 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   244 - (BOOL) exists;  // Verify if an object exists.
   245 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   246 
   247 @end
   248 
   249 // This subdivides the text into paragraphs.
   250 @interface iChatParagraph : SBObject
   251 
   252 - (SBElementArray *) characters;
   253 - (SBElementArray *) paragraphs;
   254 - (SBElementArray *) words;
   255 - (SBElementArray *) attributeRuns;
   256 - (SBElementArray *) attachments;
   257 
   258 @property (copy) NSColor *color;  // The color of the first character.
   259 @property (copy) NSString *font;  // The name of the font of the first character.
   260 @property NSInteger size;  // The size in points of the first character.
   261 
   262 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   263 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   264 - (void) delete;  // Delete an object.
   265 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   266 - (BOOL) exists;  // Verify if an object exists.
   267 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   268 
   269 @end
   270 
   271 // This subdivides the text into words.
   272 @interface iChatWord : SBObject
   273 
   274 - (SBElementArray *) characters;
   275 - (SBElementArray *) paragraphs;
   276 - (SBElementArray *) words;
   277 - (SBElementArray *) attributeRuns;
   278 - (SBElementArray *) attachments;
   279 
   280 @property (copy) NSColor *color;  // The color of the first character.
   281 @property (copy) NSString *font;  // The name of the font of the first character.
   282 @property NSInteger size;  // The size in points of the first character.
   283 
   284 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   285 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   286 - (void) delete;  // Delete an object.
   287 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   288 - (BOOL) exists;  // Verify if an object exists.
   289 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   290 
   291 @end
   292 
   293 // This subdivides the text into chunks that all have the same attributes.
   294 @interface iChatAttributeRun : SBObject
   295 
   296 - (SBElementArray *) characters;
   297 - (SBElementArray *) paragraphs;
   298 - (SBElementArray *) words;
   299 - (SBElementArray *) attributeRuns;
   300 - (SBElementArray *) attachments;
   301 
   302 @property (copy) NSColor *color;  // The color of the first character.
   303 @property (copy) NSString *font;  // The name of the font of the first character.
   304 @property NSInteger size;  // The size in points of the first character.
   305 
   306 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   307 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   308 - (void) delete;  // Delete an object.
   309 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   310 - (BOOL) exists;  // Verify if an object exists.
   311 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   312 
   313 @end
   314 
   315 // Represents an inline text attachment. This class is used mainly for make commands.
   316 @interface iChatAttachment : iChatRichText
   317 
   318 @property (copy, readonly) NSURL *file;  // The path to the file for the attachment
   319 
   320 
   321 @end
   322 
   323 
   324 
   325 /*
   326  * iChat Suite
   327  */
   328 
   329 // iChat application.
   330 @interface iChatApplication (IChatSuite)
   331 
   332 - (SBElementArray *) buddies;
   333 - (SBElementArray *) services;
   334 - (SBElementArray *) fileTransfers;
   335 - (SBElementArray *) chats;
   336 - (SBElementArray *) textChats;
   337 - (SBElementArray *) audioChats;
   338 - (SBElementArray *) videoChats;
   339 
   340 @property (readonly) NSInteger idleTime;  // Time in seconds that I have been idle.
   341 @property (copy) NSImage *image;  // My image as it appears in all services.
   342 @property (copy) NSString *statusMessage;  // My status message, visible to other people while I am online.
   343 @property iChatMyStatus status;  // My status on all services.
   344 @property (copy) iChatAudioChat *activeAvChat;  // The currently active audio or video chat.
   345 
   346 @end
   347 
   348 // A buddy on a service.
   349 @interface iChatBuddy : iChatItem
   350 
   351 - (NSString *) id;  // The buddy's service and handle. For example: AIM:JohnDoe007
   352 @property (copy, readonly) iChatService *service;  // The service on which this buddy exists.
   353 @property (copy, readonly) NSString *name;  // The buddy's name as it appears in the buddy list.
   354 @property (copy, readonly) NSString *handle;  // The buddy's online account name.
   355 @property (readonly) iChatAccountStatus status;  // The buddy's current status.
   356 @property (copy, readonly) NSString *statusMessage;  // The buddy's current status message.
   357 @property (readonly) NSInteger idleTime;  // The time in seconds the buddy has been idle.
   358 @property (copy, readonly) NSArray *capabilities;  // The buddy's messaging capabilities.
   359 @property (copy, readonly) NSImage *image;  // The buddy's custom image.
   360 @property (copy, readonly) NSString *firstName;  // The first name from this buddy's Address Book card, if available
   361 @property (copy, readonly) NSString *lastName;  // The last name from this buddy's Address Book card, if available
   362 @property (copy, readonly) NSString *fullName;  // The full name from this buddy's Address Book card, if available
   363 
   364 
   365 @end
   366 
   367 // A service that can be logged in from this system
   368 @interface iChatService : iChatItem
   369 
   370 - (SBElementArray *) buddies;
   371 - (SBElementArray *) chats;
   372 
   373 - (NSString *) id;  // A guid identifier for this service.
   374 @property (copy) NSString *name;  // The name of this service as defined in Account preferences description field
   375 @property BOOL enabled;  // Is the service enabled?
   376 @property (readonly) iChatConnectionStatus status;  // The connection status for this account.
   377 @property (readonly) iChatServiceType serviceType;  // The type of protocol for this service
   378 
   379 - (void) logIn;  // Log in to the specified service, or all services if none is specified. If the account password is not in the keychain the user will be prompted to enter one.
   380 - (void) logOut;  // Logs out of a service, or all services if none is specified.
   381 
   382 @end
   383 
   384 // An audio, video, or text chat.
   385 @interface iChatChat : SBObject
   386 
   387 - (NSString *) id;  // A guid identifier for this chat.
   388 @property (copy, readonly) iChatService *service;  // The service which is participating in this chat.
   389 @property (copy, readonly) NSArray *participants;  // Other participants of this chat. This property may be specified at time of creation.
   390 @property (readonly) BOOL secure;  // Is this chat secure?
   391 @property (readonly) BOOL invitation;  // Is this an invitation to a chat?
   392 @property (readonly) BOOL active;  // Is this chat currently active?
   393 @property (copy, readonly) NSDate *started;  // The date on which this chat started.
   394 @property (copy, readonly) NSDate *updated;  // The date when this chat was last updated.
   395 
   396 - (void) closeSaving:(iChatSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
   397 - (void) saveIn:(NSURL *)in_ as:(NSString *)as;  // Save a document.
   398 - (void) delete;  // Delete an object.
   399 - (SBObject *) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
   400 - (BOOL) exists;  // Verify if an object exists.
   401 - (SBObject *) moveTo:(SBObject *)to;  // Move object(s) to a new location.
   402 - (void) accept;  // Accepts an incoming text, audio, or video chat invitation, or file transfer
   403 - (void) decline;  // Declines an incoming text, audio, or video chat invitation, or file transfer
   404 
   405 @end
   406 
   407 // A text chat.
   408 @interface iChatTextChat : iChatChat
   409 
   410 @property (copy, readonly) NSString *subject;  // The subject of this chat, if available.
   411 @property (copy, readonly) NSString *invitationMessage;  // An invitation message. This may only be specified at the time of creation. This message will be sent to chat participants when the chat is created.
   412 @property (readonly) iChatJoinState joinState;  // How you are joined to this chat
   413 @property (copy, readonly) NSString *name;  // The address or room name of this chat. This property may be specified at time of creation.
   414 @property (readonly) iChatChatType chatType;  // The type of this chat.
   415 
   416 
   417 @end
   418 
   419 // An audio or video chat.
   420 @interface iChatAudioChat : iChatChat
   421 
   422 @property (readonly) iChatScreenSharing screenSharing;  // Type of screen sharing session taking place within this chat.
   423 @property BOOL muted;  // Is the chat muted?
   424 @property (readonly) iChatAvConnectionStatus avConnectionStatus;  // The connection state for this av chat.
   425 
   426 - (void) requestRecording;  // Sends a recording request to all participants of an audio or video chat. Recording will not start until all participants have agreed to allow recording.
   427 - (void) stopRecording;  // Ends recording of an audio or video chat.
   428 
   429 @end
   430 
   431 @interface iChatVideoChat : iChatAudioChat
   432 
   433 @property BOOL paused;  // Is the chat paused?
   434 @property BOOL showingFullScreen;  // Is the chat being displayed in full screen mode?
   435 @property BOOL showingLocalVideo;  // Is the local video preview being displayed?
   436 
   437 - (void) takeSnapshot;  // Takes a snapshot of a video chat and saves it to a desktop.
   438 
   439 @end
   440 
   441 // A file being sent or received
   442 @interface iChatFileTransfer : iChatItem
   443 
   444 - (NSString *) id;  // The guid for this file transfer
   445 @property (copy, readonly) NSString *name;  // The name of this file
   446 @property (copy, readonly) NSURL *file;  // The local path to this file transfer
   447 @property (readonly) iChatDirection direction;  // The direction in which this file is being sent
   448 @property (copy, readonly) iChatService *service;  // The service on which this file transfer is taking place
   449 @property (copy, readonly) iChatBuddy *buddy;  // The account participating in this file transfer
   450 @property (readonly) BOOL secure;  // Is this file transfer secure?
   451 @property (readonly) NSInteger fileSize;  // The total size in bytes of the completed file transfer
   452 @property (readonly) NSInteger fileProgress;  // The number of bytes that have been transferred
   453 @property (readonly) iChatTransferStatus transferStatus;  // The current status of this file transfer
   454 @property (copy, readonly) NSDate *started;  // The date that this file transfer started
   455 
   456 - (void) accept;  // Accepts an incoming text, audio, or video chat invitation, or file transfer
   457 - (void) decline;  // Declines an incoming text, audio, or video chat invitation, or file transfer
   458 
   459 @end
   460