StropheCappuccino API 1.0.0
/tmp/tempDoc.doc/Build/StropheCappuccino.build/Debug/CommonJS.environment/Sources/TNStropheContact.j
Go to the documentation of this file.
00001 @STATIC;1.0;I;23;Foundation/Foundation.jI;16;AppKit/CPImage.ji;21;TNStropheConnection.ji;16;TNStropheGroup.ji;14;TNStropheJID.ji;16;TNStropheVCard.jt;32349;objj_executeFile("Foundation/Foundation.j", NO);
00002 objj_executeFile("AppKit/CPImage.j", NO);
00003 objj_executeFile("TNStropheConnection.j", YES);
00004 objj_executeFile("TNStropheGroup.j", YES);
00005 objj_executeFile("TNStropheJID.j", YES);
00006 objj_executeFile("TNStropheVCard.j", YES);
00007 TNStropheContactStatusAway = "away";
00008 TNStropheContactStatusBusy = "xa";
00009 TNStropheContactStatusDND = "dnd";
00010 TNStropheContactStatusOffline = "offline";
00011 TNStropheContactStatusOnline = "online";
00012 TNStropheContactGroupUpdatedNotification = "TNStropheContactGroupUpdatedNotification";
00013 TNStropheContactMessageActiveNotification = "TNStropheContactMessageActiveNotification";
00014 TNStropheContactMessageComposingNotification = "TNStropheContactMessageComposingNotification";
00015 TNStropheContactMessageGoneNotification = "TNStropheContactMessageGoneNotification";
00016 TNStropheContactMessageInactiveNotification = "TNStropheContactMessageInactiveNotification";
00017 TNStropheContactMessagePausedNotification = "TNStropheContactMessagePausedNotification";
00018 TNStropheContactMessageReceivedNotification = "TNStropheContactMessageReceivedNotification";
00019 TNStropheContactMessageSentNotification = "TNStropheContactMessageSentNotification";
00020 TNStropheContactMessageTreatedNotification = "TNStropheContactMessageTreatedNotification";
00021 TNStropheContactNicknameUpdatedNotification = "TNStropheContactNicknameUpdatedNotification";
00022 TNStropheContactPresenceUpdatedNotification = "TNStropheContactPresenceUpdatedNotification";
00023 TNStropheContactStanzaSentNotification = "TNStropheContactStanzaSentNotification"
00024 TNStropheContactSubscriptionUpdatedNotification = "TNStropheContactSubscriptionUpdatedNotification";
00025 TNStropheContactVCardReceivedNotification = "TNStropheContactVCardReceivedNotification";
00026 var TNStropheContactDelegate_avatarForContact_ = 1 << 0;
00027 TNStropheContactImageOffline = nil;
00028 TNStropheContactImageOnline = nil;
00029 TNStropheContactImageBusy = nil;
00030 TNStropheContactImageAway = nil;
00031 TNStropheContactImageDND = nil;
00032 TNStropheContactImageNewMessage = nil;
00033 TNStropheContactImageNewError = nil;
00034 {var the_class = objj_allocateClassPair(CPObject, "TNStropheContact"),
00035 meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_groups"), new objj_ivar("_messagesQueue"), new objj_ivar("_resources"), new objj_ivar("_avatar"), new objj_ivar("_statusIcon"), new objj_ivar("_numberOfEvents"), new objj_ivar("_nickname"), new objj_ivar("_nodeName"), new objj_ivar("_subscription"), new objj_ivar("_type"), new objj_ivar("_XMPPShow"), new objj_ivar("_XMPPStatus"), new objj_ivar("_delegate"), new objj_ivar("_connection"), new objj_ivar("_JID"), new objj_ivar("_vCard"), new objj_ivar("_askingVCard"), new objj_ivar("_isComposing"), new objj_ivar("_statusReminder"), new objj_ivar("_implementedDelegateMethods")]);//#pragma mark -
00036 //#pragma mark Class methods
00037 
00038 //#pragma mark -
00039 //#pragma mark Initialization
00040 
00041 
00042 //#pragma mark -
00043 //#pragma mark Setters and Getters
00044 
00045 
00046 //#pragma mark -
00047 //#pragma mark Status
00048 
00049 
00050 
00051 
00052 
00053 //#pragma mark -
00054 //#pragma mark Subscription
00055 
00056 
00057 
00058 
00059 //#pragma mark -
00060 //#pragma mark MetaData
00061 
00062 
00063 
00064 //#pragma mark -
00065 //#pragma mark Communicating
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 //#pragma mark -
00081 //#pragma mark Delegates
00082 objj_registerClassPair(the_class);
00083 class_addMethods(the_class, [new objj_method(sel_getUid("groups"), function $TNStropheContact__groups(self, _cmd)
00084 {
00085 return self._groups;
00086 }
00087 ,["CPArray"]), new objj_method(sel_getUid("setGroups:"), function $TNStropheContact__setGroups_(self, _cmd, newValue)
00088 {
00089 self._groups = newValue;
00090 }
00091 ,["void","CPArray"]), new objj_method(sel_getUid("messagesQueue"), function $TNStropheContact__messagesQueue(self, _cmd)
00092 {
00093 return self._messagesQueue;
00094 }
00095 ,["CPArray"]), new objj_method(sel_getUid("setMessagesQueue:"), function $TNStropheContact__setMessagesQueue_(self, _cmd, newValue)
00096 {
00097 self._messagesQueue = newValue;
00098 }
00099 ,["void","CPArray"]), new objj_method(sel_getUid("resources"), function $TNStropheContact__resources(self, _cmd)
00100 {
00101 return self._resources;
00102 }
00103 ,["CPArray"]), new objj_method(sel_getUid("setResources:"), function $TNStropheContact__setResources_(self, _cmd, newValue)
00104 {
00105 self._resources = newValue;
00106 }
00107 ,["void","CPArray"]), new objj_method(sel_getUid("avatar"), function $TNStropheContact__avatar(self, _cmd)
00108 {
00109 return self._avatar;
00110 }
00111 ,["CPImage"]), new objj_method(sel_getUid("setAvatar:"), function $TNStropheContact__setAvatar_(self, _cmd, newValue)
00112 {
00113 self._avatar = newValue;
00114 }
00115 ,["void","CPImage"]), new objj_method(sel_getUid("statusIcon"), function $TNStropheContact__statusIcon(self, _cmd)
00116 {
00117 return self._statusIcon;
00118 }
00119 ,["CPImage"]), new objj_method(sel_getUid("setStatusIcon:"), function $TNStropheContact__setStatusIcon_(self, _cmd, newValue)
00120 {
00121 self._statusIcon = newValue;
00122 }
00123 ,["void","CPImage"]), new objj_method(sel_getUid("numberOfEvents"), function $TNStropheContact__numberOfEvents(self, _cmd)
00124 {
00125 return self._numberOfEvents;
00126 }
00127 ,["CPNumber"]), new objj_method(sel_getUid("setNumberOfEvents:"), function $TNStropheContact__setNumberOfEvents_(self, _cmd, newValue)
00128 {
00129 self._numberOfEvents = newValue;
00130 }
00131 ,["void","CPNumber"]), new objj_method(sel_getUid("nickname"), function $TNStropheContact__nickname(self, _cmd)
00132 {
00133 return self._nickname;
00134 }
00135 ,["CPString"]), new objj_method(sel_getUid("setNickname:"), function $TNStropheContact__setNickname_(self, _cmd, newValue)
00136 {
00137 self._nickname = newValue;
00138 }
00139 ,["void","CPString"]), new objj_method(sel_getUid("nodeName"), function $TNStropheContact__nodeName(self, _cmd)
00140 {
00141 return self._nodeName;
00142 }
00143 ,["CPString"]), new objj_method(sel_getUid("setNodeName:"), function $TNStropheContact__setNodeName_(self, _cmd, newValue)
00144 {
00145 self._nodeName = newValue;
00146 }
00147 ,["void","CPString"]), new objj_method(sel_getUid("subscription"), function $TNStropheContact__subscription(self, _cmd)
00148 {
00149 return self._subscription;
00150 }
00151 ,["CPString"]), new objj_method(sel_getUid("setSubscription:"), function $TNStropheContact__setSubscription_(self, _cmd, newValue)
00152 {
00153 self._subscription = newValue;
00154 }
00155 ,["void","CPString"]), new objj_method(sel_getUid("type"), function $TNStropheContact__type(self, _cmd)
00156 {
00157 return self._type;
00158 }
00159 ,["CPString"]), new objj_method(sel_getUid("setType:"), function $TNStropheContact__setType_(self, _cmd, newValue)
00160 {
00161 self._type = newValue;
00162 }
00163 ,["void","CPString"]), new objj_method(sel_getUid("XMPPShow"), function $TNStropheContact__XMPPShow(self, _cmd)
00164 {
00165 return self._XMPPShow;
00166 }
00167 ,["CPString"]), new objj_method(sel_getUid("setXMPPShow:"), function $TNStropheContact__setXMPPShow_(self, _cmd, newValue)
00168 {
00169 self._XMPPShow = newValue;
00170 }
00171 ,["void","CPString"]), new objj_method(sel_getUid("XMPPStatus"), function $TNStropheContact__XMPPStatus(self, _cmd)
00172 {
00173 return self._XMPPStatus;
00174 }
00175 ,["CPString"]), new objj_method(sel_getUid("setXMPPStatus:"), function $TNStropheContact__setXMPPStatus_(self, _cmd, newValue)
00176 {
00177 self._XMPPStatus = newValue;
00178 }
00179 ,["void","CPString"]), new objj_method(sel_getUid("delegate"), function $TNStropheContact__delegate(self, _cmd)
00180 {
00181 return self._delegate;
00182 }
00183 ,["id"]), new objj_method(sel_getUid("_setDelegate:"), function $TNStropheContact___setDelegate_(self, _cmd, newValue)
00184 {
00185 self._delegate = newValue;
00186 }
00187 ,["void","id"]), new objj_method(sel_getUid("connection"), function $TNStropheContact__connection(self, _cmd)
00188 {
00189 return self._connection;
00190 }
00191 ,["TNStropheConnection"]), new objj_method(sel_getUid("setConnection:"), function $TNStropheContact__setConnection_(self, _cmd, newValue)
00192 {
00193 self._connection = newValue;
00194 }
00195 ,["void","TNStropheConnection"]), new objj_method(sel_getUid("JID"), function $TNStropheContact__JID(self, _cmd)
00196 {
00197 return self._JID;
00198 }
00199 ,["TNStropheJID"]), new objj_method(sel_getUid("setJID:"), function $TNStropheContact__setJID_(self, _cmd, newValue)
00200 {
00201 self._JID = newValue;
00202 }
00203 ,["void","TNStropheJID"]), new objj_method(sel_getUid("vCard"), function $TNStropheContact__vCard(self, _cmd)
00204 {
00205 return self._vCard;
00206 }
00207 ,["TNStropheVCard"]), new objj_method(sel_getUid("setVCard:"), function $TNStropheContact__setVCard_(self, _cmd, newValue)
00208 {
00209 self._vCard = newValue;
00210 }
00211 ,["void","TNStropheVCard"]), new objj_method(sel_getUid("initWithConnection:JID:group:"), function $TNStropheContact__initWithConnection_JID_group_(self, _cmd, aConnection, aJID, aGroup)
00212 {
00213     if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("TNStropheContact").super_class }, "init"))
00214     {
00215         self._type = "contact";
00216         self._connection = aConnection;
00217         self._messagesQueue = objj_msgSend(CPArray, "array");
00218         self._numberOfEvents = 0;
00219         self._isComposing = NO;
00220         self._askingVCard = NO;
00221         self._resources = objj_msgSend(CPArray, "array");
00222         self._groups = objj_msgSend(CPArray, "array");
00223         objj_msgSend(self, "setNickname:", objj_msgSend(self._JID, "bare"));
00224         objj_msgSend(self, "setJID:", aJID);
00225         objj_msgSend(self, "setXMPPStatus:", "Offline");
00226         objj_msgSend(self, "setXMPPShow:", TNStropheContactStatusOffline);
00227         objj_msgSend(self, "setStatusIcon:", TNStropheContactImageOffline);
00228         if (aGroup)
00229             objj_msgSend(self._groups, "addObject:", aGroup);
00230     }
00231     return self;
00232 }
00233 ,["id","TNStropheConnection","TNStropheJID","TNStropheGroup"]), new objj_method(sel_getUid("setDelegate:"), function $TNStropheContact__setDelegate_(self, _cmd, aDelegate)
00234 {
00235     if (aDelegate == self._delegate)
00236         return;
00237     self._delegate = aDelegate;
00238     self._implementedDelegateMethods = 0;
00239     if (objj_msgSend(self._delegate, "respondsToSelector:", sel_getUid("avatarForContact:")))
00240         self._implementedDelegateMethods |= TNStropheContactDelegate_avatarForContact_;
00241 }
00242 ,["void","id"]), new objj_method(sel_getUid("name"), function $TNStropheContact__name(self, _cmd)
00243 {
00244     return objj_msgSend(self._vCard, "fullName") || self._nickname;
00245 }
00246 ,["CPString"]), new objj_method(sel_getUid("_didReceivePresence:"), function $TNStropheContact___didReceivePresence_(self, _cmd, aStanza)
00247 {
00248     var resource = objj_msgSend(aStanza, "fromResource"),
00249         presenceStatus = objj_msgSend(aStanza, "firstChildWithName:", "status");
00250     if (resource && (typeof(resource) != "undefined") && resource != "")
00251     {
00252         if (!objj_msgSend(self._resources, "containsObject:", resource))
00253             objj_msgSend(self._resources, "addObject:", resource);
00254         objj_msgSend(self._JID, "setResource:", resource);
00255     }
00256     switch (objj_msgSend(aStanza, "type"))
00257     {
00258         case "error":
00259             var errorCode = objj_msgSend(objj_msgSend(aStanza, "firstChildWithName:", "error"), "valueForAttribute:", "code");
00260             objj_msgSend(self, "setXMPPShow:", TNStropheContactStatusOffline);
00261             objj_msgSend(self, "setXMPPStatus:", "Error code: " + errorCode);
00262             objj_msgSend(self, "setStatusIcon:", TNStropheContactImageNewError);
00263             self._statusReminder = TNStropheContactImageNewError;
00264             return NO;
00265         case "unavailable":
00266             objj_msgSend(self._resources, "removeObject:", resource);
00267             CPLogConsole("contact become unavailable from resource: " + resource + ". Resources left : " + self._resources + "("+ objj_msgSend(self._resources, "count") + ")");
00268             if (objj_msgSend(self._resources, "count") == 0)
00269             {
00270                 objj_msgSend(self, "setXMPPShow:", TNStropheContactStatusOffline);
00271                 objj_msgSend(self, "setStatusIcon:", TNStropheContactImageOffline);
00272                 self._statusReminder = TNStropheContactImageOffline;
00273                 if (presenceStatus)
00274                     objj_msgSend(self, "setXMPPStatus:", objj_msgSend(presenceStatus, "text"));
00275                 else
00276                     objj_msgSend(self, "setXMPPStatus:", "Offline");
00277             }
00278             else
00279                 objj_msgSend(self._JID, "setResource:", objj_msgSend(self._resources, "lastObject"));
00280             break;
00281         case "subscribe":
00282             objj_msgSend(self, "setXMPPStatus:", "Asking subscribtion");
00283             objj_msgSend(self, "setSubscription:", objj_msgSend(aStanza, "type"));
00284             break;
00285         case "subscribed":
00286             objj_msgSend(self, "setSubscription:", objj_msgSend(aStanza, "type"));
00287             break;
00288         case "unsubscribe":
00289             objj_msgSend(self, "setSubscription:", objj_msgSend(aStanza, "type"));
00290             break;
00291         case "unsubscribed":
00292             objj_msgSend(self, "setSubscription:", objj_msgSend(aStanza, "type"));
00293             objj_msgSend(self, "setXMPPStatus:", "Unauthorized");
00294             break;
00295         default:
00296             objj_msgSend(self, "setXMPPShow:", TNStropheContactStatusOnline);
00297             objj_msgSend(self, "setStatusIcon:", TNStropheContactImageOnline);
00298             objj_msgSend(self, "setSubscription:", "subscribed");
00299             self._statusReminder = TNStropheContactImageOnline;
00300             if (objj_msgSend(aStanza, "firstChildWithName:", "show"))
00301             {
00302                 objj_msgSend(self, "setXMPPShow:", objj_msgSend(objj_msgSend(aStanza, "firstChildWithName:", "show"), "text"));
00303                 switch (self._XMPPShow)
00304                 {
00305                     case TNStropheContactStatusBusy:
00306                         objj_msgSend(self, "setStatusIcon:", TNStropheContactImageBusy);
00307                         self._statusReminder = TNStropheContactImageBusy;
00308                         break;
00309                     case TNStropheContactStatusAway:
00310                         objj_msgSend(self, "setStatusIcon:", TNStropheContactImageAway);
00311                         self._statusReminder = TNStropheContactImageAway;
00312                         break;
00313                     case TNStropheContactStatusDND:
00314                         objj_msgSend(self, "setStatusIcon:", TNStropheContactImageDND);
00315                         self._statusReminder = TNStropheContactImageDND;
00316                         break;
00317                 }
00318             }
00319             if (self._numberOfEvents > 0)
00320                 objj_msgSend(self, "setStatusIcon:", TNStropheContactImageNewMessage);
00321             if (presenceStatus)
00322                 objj_msgSend(self, "setXMPPStatus:", objj_msgSend(presenceStatus, "text"));
00323             else
00324                 objj_msgSend(self, "setXMPPStatus:", "Online");
00325             if (objj_msgSend(aStanza, "firstChildWithName:", "x")
00326                 && objj_msgSend(objj_msgSend(aStanza, "firstChildWithName:", "x"), "valueForAttribute:", "xmlns") == "vcard-temp:x:update"
00327                 && !objj_msgSend(aStanza, "firstChildWithName:", "delay"))
00328             {
00329                 objj_msgSend(self, "getVCard");
00330             }
00331             break;
00332     }
00333     if (!(objj_msgSend(aStanza, "firstChildWithName:", "x") && objj_msgSend(objj_msgSend(aStanza, "firstChildWithName:", "x"), "valueForAttribute:", "xmlns") == "vcard-temp:x:update"))
00334         objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", TNStropheContactPresenceUpdatedNotification, self);
00335     return YES;
00336 }
00337 ,["BOOL","TNStropheStanza"]), new objj_method(sel_getUid("sendStatus:"), function $TNStropheContact__sendStatus_(self, _cmd, aStatus)
00338 {
00339     var statusStanza = objj_msgSend(TNStropheStanza, "messageTo:withAttributes:", self._JID, {"type": "chat"});
00340     objj_msgSend(statusStanza, "addChildWithName:andAttributes:", aStatus, {"xmlns": "http://jabber.org/protocol/chatstates"});
00341     objj_msgSend(self, "sendStanza:andRegisterSelector:ofObject:", statusStanza, sel_getUid("_didSendStatus:"), self);
00342 }
00343 ,["void","CPString"]), new objj_method(sel_getUid("_didSendStatus:"), function $TNStropheContact___didSendStatus_(self, _cmd, aStanza)
00344 {
00345     if (objj_msgSend(aStanza, "type") == "error")
00346         CPLog.error("Unable to send status. Resp is: " + aStanza);
00347 }
00348 ,["void","TNStropheStanza"]), new objj_method(sel_getUid("sendComposing"), function $TNStropheContact__sendComposing(self, _cmd)
00349 {
00350     if (self._isComposing)
00351         return;
00352     objj_msgSend(self, "sendStatus:", "composing");
00353     self._isComposing = YES;
00354 }
00355 ,["void"]), new objj_method(sel_getUid("sendComposePaused"), function $TNStropheContact__sendComposePaused(self, _cmd)
00356 {
00357     objj_msgSend(self, "sendStatus:", "paused");
00358     self._isComposing = NO;
00359 }
00360 ,["void"]), new objj_method(sel_getUid("subscribe"), function $TNStropheContact__subscribe(self, _cmd)
00361 {
00362     objj_msgSend(self._connection, "send:", objj_msgSend(TNStropheStanza, "presenceTo:withAttributes:bare:", self._JID, {"type": "subscribed"}, YES));
00363 }
00364 ,["void"]), new objj_method(sel_getUid("unsubscribe"), function $TNStropheContact__unsubscribe(self, _cmd)
00365 {
00366     objj_msgSend(self._connection, "send:", objj_msgSend(TNStropheStanza, "presenceTo:withAttributes:bare:", self._JID, {"type": "unsubscribed"}, YES));
00367 }
00368 ,["void"]), new objj_method(sel_getUid("askSubscription"), function $TNStropheContact__askSubscription(self, _cmd)
00369 {
00370     objj_msgSend(self._connection, "send:", objj_msgSend(TNStropheStanza, "presenceTo:withAttributes:bare:", self._JID, {"type": "subscribe"}, YES));
00371 }
00372 ,["void"]), new objj_method(sel_getUid("setSubscription:"), function $TNStropheContact__setSubscription_(self, _cmd, aSubscription)
00373 {
00374     objj_msgSend(self, "willChangeValueForKey:", "subscription");
00375     self._subscription = aSubscription;
00376     objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", TNStropheContactSubscriptionUpdatedNotification, self);
00377     objj_msgSend(self, "didChangeValueForKey:", "subscription");
00378 }
00379 ,["void","CPString"]), new objj_method(sel_getUid("description"), function $TNStropheContact__description(self, _cmd)
00380 {
00381     return self._nickname;
00382 }
00383 ,["CPString"]), new objj_method(sel_getUid("getVCard"), function $TNStropheContact__getVCard(self, _cmd)
00384 {
00385     var uid = objj_msgSend(self._connection, "getUniqueId"),
00386         vcardStanza = objj_msgSend(TNStropheStanza, "iqTo:withAttributes:bare:", self._JID, {"type": "get", "id": uid}, YES),
00387         params = objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", uid, "id");
00388     objj_msgSend(vcardStanza, "addChildWithName:andAttributes:", "vCard", {"xmlns": "vcard-temp"});
00389     self._askingVCard = YES;
00390     objj_msgSend(self._connection, "registerSelector:ofObject:withDict:", sel_getUid("_didReceiveVCard:"), self, params);
00391     objj_msgSend(self._connection, "send:", vcardStanza);
00392 }
00393 ,["void"]), new objj_method(sel_getUid("_didReceiveVCard:"), function $TNStropheContact___didReceiveVCard_(self, _cmd, aStanza)
00394 {
00395     var aVCard = objj_msgSend(aStanza, "firstChildWithName:", "vCard");
00396     self._askingVCard = NO;
00397     self._avatar = nil;
00398     if (aVCard)
00399     {
00400         var VCARD = objj_msgSend(objj_msgSend(TNStropheVCard, "alloc"), "initWithXMLNode:", aVCard);
00401         if (!self._nickname || (self._nickname == objj_msgSend(self._JID, "bare")) || (self._nickname == objj_msgSend(self._JID, "node")))
00402             objj_msgSend(self, "setNickname:", objj_msgSend(VCARD, "fullName") || objj_msgSend(self._JID, "node"))
00403         if (objj_msgSend(VCARD, "photo"))
00404             objj_msgSend(self, "setAvatar:", objj_msgSend(VCARD, "photo"));
00405         else if (self._implementedDelegateMethods & TNStropheContactDelegate_avatarForContact_)
00406             objj_msgSend(self, "setAvatar:", objj_msgSend(self._delegate, "avatarForContact:", self));
00407         objj_msgSend(self, "willChangeValueForKey:", "name");
00408         objj_msgSend(self, "setVCard:", VCARD);
00409         objj_msgSend(self, "didChangeValueForKey:", "name");
00410         objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", TNStropheContactVCardReceivedNotification, self);
00411     }
00412     return NO;
00413 }
00414 ,["BOOL","TNStropheStanza"]), new objj_method(sel_getUid("sendStanza:"), function $TNStropheContact__sendStanza_(self, _cmd, aStanza)
00415 {
00416     objj_msgSend(self, "sendStanza:withUserInfo:", aStanza, nil);
00417 }
00418 ,["void","TNStropheStanza"]), new objj_method(sel_getUid("sendStanza:withUserInfo:"), function $TNStropheContact__sendStanza_withUserInfo_(self, _cmd, aStanza, userInfo)
00419 {
00420     objj_msgSend(aStanza, "setTo:", self._JID);
00421     objj_msgSend(self._connection, "send:", aStanza);
00422     objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:userInfo:", TNStropheContactStanzaSentNotification, self, userInfo);
00423 }
00424 ,["void","TNStropheStanza","CPDictionary"]), new objj_method(sel_getUid("sendStanza:andRegisterSelector:ofObject:withSpecificID:userInfo:handlerDelegate:"), function $TNStropheContact__sendStanza_andRegisterSelector_ofObject_withSpecificID_userInfo_handlerDelegate_(self, _cmd, aStanza, aSelector, anObject, anId, someUserInfo, aDelegate)
00425 {
00426     var params = objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", anId, "id"),
00427         userInfo = objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", aStanza, "stanza", anId, "id"),
00428         ret;
00429     objj_msgSend(aStanza, "setID:", anId);
00430     if (aSelector && someUserInfo && aDelegate)
00431         ret = objj_msgSend(self._connection, "registerSelector:ofObject:withDict:userInfo:handlerDelegate:", aSelector, anObject, params, someUserInfo, aDelegate);
00432     else if (aSelector && !someUserInfo && aDelegate)
00433         ret = objj_msgSend(self._connection, "registerSelector:ofObject:withDict:handlerDelegate:", aSelector, anObject, params, aDelegate);
00434     else if (aSelector && someUserInfo && !aDelegate)
00435         ret = objj_msgSend(self._connection, "registerSelector:ofObject:withDict:userInfo:", aSelector, anObject, params, someUserInfo);
00436     else if (aSelector && !someUserInfo && !aDelegate)
00437         ret = objj_msgSend(self._connection, "registerSelector:ofObject:withDict:", aSelector, anObject, params);
00438     objj_msgSend(self, "sendStanza:withUserInfo:", aStanza, userInfo);
00439     return ret;
00440 }
00441 ,["id","TNStropheStanza","SEL","id","id","id","id"]), new objj_method(sel_getUid("sendStanza:andRegisterSelector:ofObject:"), function $TNStropheContact__sendStanza_andRegisterSelector_ofObject_(self, _cmd, aStanza, aSelector, anObject)
00442 {
00443     return objj_msgSend(self, "sendStanza:andRegisterSelector:ofObject:withSpecificID:userInfo:handlerDelegate:", aStanza, aSelector, anObject, objj_msgSend(self._connection, "getUniqueId"), nil, nil);
00444 }
00445 ,["id","TNStropheStanza","SEL","id"]), new objj_method(sel_getUid("sendStanza:andRegisterSelector:ofObject:withSpecificID:"), function $TNStropheContact__sendStanza_andRegisterSelector_ofObject_withSpecificID_(self, _cmd, aStanza, aSelector, anObject, anId)
00446 {
00447     return objj_msgSend(self, "sendStanza:andRegisterSelector:ofObject:withSpecificID:userInfo:handlerDelegate:", aStanza, aSelector, anObject, anId, nil, nil);
00448 }
00449 ,["id","TNStropheStanza","SEL","id","int"]), new objj_method(sel_getUid("sendStanza:andRegisterSelector:ofObject:userInfo:"), function $TNStropheContact__sendStanza_andRegisterSelector_ofObject_userInfo_(self, _cmd, aStanza, aSelector, anObject, someUserInfo)
00450 {
00451     return objj_msgSend(self, "sendStanza:andRegisterSelector:ofObject:withSpecificID:userInfo:handlerDelegate:", aStanza, aSelector, anObject, objj_msgSend(self._connection, "getUniqueId"), someUserInfo, nil);
00452 }
00453 ,["id","TNStropheStanza","SEL","id","id"]), new objj_method(sel_getUid("sendStanza:andRegisterSelector:ofObject:handlerDelegate:"), function $TNStropheContact__sendStanza_andRegisterSelector_ofObject_handlerDelegate_(self, _cmd, aStanza, aSelector, anObject, aDelegate)
00454 {
00455     return objj_msgSend(self, "sendStanza:andRegisterSelector:ofObject:withSpecificID:userInfo:handlerDelegate:", aStanza, aSelector, anObject, objj_msgSend(self._connection, "getUniqueId"), nil, aDelegate);
00456 }
00457 ,["id","TNStropheStanza","SEL","id","id"]), new objj_method(sel_getUid("getMessages"), function $TNStropheContact__getMessages(self, _cmd)
00458 {
00459     var params = objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", "message", "name", objj_msgSend(self._JID, "bare"), "from", {matchBare: true}, "options");
00460     objj_msgSend(self._connection, "registerSelector:ofObject:withDict:", sel_getUid("_didReceiveMessage:"), self, params);
00461 }
00462 ,["void"]), new objj_method(sel_getUid("_didReceiveMessage:"), function $TNStropheContact___didReceiveMessage_(self, _cmd, aStanza)
00463 {
00464     var center = objj_msgSend(CPNotificationCenter, "defaultCenter"),
00465         userInfo = objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", aStanza, "stanza", objj_msgSend(CPDate, "date"), "date");
00466     if (objj_msgSend(aStanza, "containsChildrenWithName:", "composing"))
00467         objj_msgSend(center, "postNotificationName:object:userInfo:", TNStropheContactMessageComposingNotification, self, userInfo);
00468     if (objj_msgSend(aStanza, "containsChildrenWithName:", "paused"))
00469         objj_msgSend(center, "postNotificationName:object:userInfo:", TNStropheContactMessagePausedNotification, self, userInfo);
00470     if (objj_msgSend(aStanza, "containsChildrenWithName:", "active"))
00471         objj_msgSend(center, "postNotificationName:object:userInfo:", TNStropheContactMessageActiveNotification, self, userInfo);
00472     if (objj_msgSend(aStanza, "containsChildrenWithName:", "inactive"))
00473         objj_msgSend(center, "postNotificationName:object:userInfo:", TNStropheContactMessageInactiveNotification, self, userInfo);
00474     if (objj_msgSend(aStanza, "containsChildrenWithName:", "gone"))
00475         objj_msgSend(center, "postNotificationName:object:userInfo:", TNStropheContactMessageGoneNotification, self, userInfo);
00476     if (objj_msgSend(aStanza, "containsChildrenWithName:", "body"))
00477     {
00478         self._statusIcon = TNStropheContactImageNewMessage;
00479         objj_msgSend(self._messagesQueue, "addObject:", aStanza);
00480         self._numberOfEvents++;
00481         objj_msgSend(center, "postNotificationName:object:userInfo:", TNStropheContactMessageReceivedNotification, self, userInfo);
00482     }
00483     return YES;
00484 }
00485 ,["BOOL","id"]), new objj_method(sel_getUid("sendMessage:"), function $TNStropheContact__sendMessage_(self, _cmd, aMessage)
00486 {
00487     objj_msgSend(self, "sendMessage:withType:", aMessage, "chat");
00488 }
00489 ,["void","CPString"]), new objj_method(sel_getUid("sendMessage:withType:"), function $TNStropheContact__sendMessage_withType_(self, _cmd, aMessage, aType)
00490 {
00491     var messageStanza = objj_msgSend(TNStropheStanza, "messageWithAttributes:", {"type":aType});
00492     objj_msgSend(messageStanza, "addChildWithName:", "body");
00493     objj_msgSend(messageStanza, "addTextNode:", aMessage);
00494     objj_msgSend(self, "sendStanza:andRegisterSelector:ofObject:", messageStanza, sel_getUid("_didSendMessage:"), self);
00495 }
00496 ,["void","CPString","CPString"]), new objj_method(sel_getUid("_didSendMessage:"), function $TNStropheContact___didSendMessage_(self, _cmd, aStanza)
00497 {
00498     if (objj_msgSend(aStanza, "type") == "error")
00499         CPLog.error("Unable to send message. Resp is: " + aStanza);
00500 }
00501 ,["void","TNStropheStanza"]), new objj_method(sel_getUid("popMessagesQueue"), function $TNStropheContact__popMessagesQueue(self, _cmd)
00502 {
00503     if (objj_msgSend(self._messagesQueue, "count") == 0)
00504         return;
00505     var message = objj_msgSend(self._messagesQueue, "objectAtIndex:", 0);
00506     self._numberOfEvents--;
00507     if (self._numberOfEvents === 0)
00508         self._statusIcon = self._statusReminder;
00509     objj_msgSend(self._messagesQueue, "removeObjectAtIndex:", 0);
00510     objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", TNStropheContactMessageTreatedNotification, self);
00511     return message;
00512 }
00513 ,["TNStropheStanza"]), new objj_method(sel_getUid("freeMessagesQueue"), function $TNStropheContact__freeMessagesQueue(self, _cmd)
00514 {
00515     self._numberOfEvents = 0;
00516     objj_msgSend(self, "setStatusIcon:", self._statusReminder);
00517     objj_msgSend(self._messagesQueue, "removeAllObjects");
00518     objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", TNStropheContactMessageTreatedNotification, self);
00519 }
00520 ,["void"]), new objj_method(sel_getUid("imageDidLoad:"), function $TNStropheContact__imageDidLoad_(self, _cmd, anImage)
00521 {
00522     objj_msgSend(anImage, "setDelegate:", nil);
00523     objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", TNStropheContactVCardReceivedNotification, self);
00524 }
00525 ,["void","CPImage"])]);
00526 class_addMethods(meta_class, [new objj_method(sel_getUid("contactWithConnection:JID:group:"), function $TNStropheContact__contactWithConnection_JID_group_(self, _cmd, aConnection, aJID, aGroup)
00527 {
00528     return objj_msgSend(objj_msgSend(TNStropheContact, "alloc"), "initWithConnection:JID:group:", aConnection, aJID, aGroup);
00529 }
00530 ,["TNStropheContact","TNStropheConnection","TNStropheJID","TNStropheGroup"]), new objj_method(sel_getUid("initialize"), function $TNStropheContact__initialize(self, _cmd)
00531 {
00532     var bundle = objj_msgSend(CPBundle, "bundleForClass:", TNStropheContact);
00533     TNStropheContactImageOffline = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "gray.png"), CGSizeMake(8.0, 8.0));
00534     TNStropheContactImageOnline = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "green.png"), CGSizeMake(8.0, 8.0));
00535     TNStropheContactImageBusy = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "red.png"), CGSizeMake(8.0, 8.0));
00536     TNStropheContactImageAway = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "orange.png"), CGSizeMake(8.0, 8.0));
00537     TNStropheContactImageDND = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "black.png"), CGSizeMake(8.0, 8.0));
00538     TNStropheContactImageNewMessage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "blue.png"), CGSizeMake(8.0, 8.0));
00539     TNStropheContactImageNewError = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "error.png"), CGSizeMake(8.0, 8.0));
00540 }
00541 ,["void"])]);
00542 }
00543 {
00544 var the_class = objj_getClass("TNStropheContact")
00545 if(!the_class) throw new SyntaxError("*** Could not find definition for class \"TNStropheContact\"");
00546 var meta_class = the_class.isa;
00547 class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $TNStropheContact__initWithCoder_(self, _cmd, aCoder)
00548 {
00549     if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("TNStropheContact").super_class }, "init"))
00550     {
00551         self._JID = objj_msgSend(aCoder, "decodeObjectForKey:", "_JID");
00552         self._nodeName = objj_msgSend(aCoder, "decodeObjectForKey:", "_nodeName");
00553         self._groups = objj_msgSend(aCoder, "decodeObjectForKey:", "_groups");
00554         self._nickname = objj_msgSend(aCoder, "decodeObjectForKey:", "_nickname");
00555         self._XMPPStatus = objj_msgSend(aCoder, "decodeObjectForKey:", "_XMPPStatus");
00556         self._resources = objj_msgSend(aCoder, "decodeObjectForKey:", "_resources");
00557         self._XMPPShow = objj_msgSend(aCoder, "decodeObjectForKey:", "_XMPPShow");
00558         self._statusIcon = objj_msgSend(aCoder, "decodeObjectForKey:", "_statusIcon");
00559         self._type = objj_msgSend(aCoder, "decodeObjectForKey:", "_type");
00560         self._vCard = objj_msgSend(aCoder, "decodeObjectForKey:", "_vCard");
00561         self._numberOfEvents = objj_msgSend(aCoder, "decodeObjectForKey:", "_numberOfEvents");
00562     }
00563     return self;
00564 }
00565 ,["id","CPCoder"]), new objj_method(sel_getUid("encodeWithCoder:"), function $TNStropheContact__encodeWithCoder_(self, _cmd, aCoder)
00566 {
00567     objj_msgSend(aCoder, "encodeObject:forKey:", self._JID, "_JID");
00568     objj_msgSend(aCoder, "encodeObject:forKey:", self._nodeName, "_nodeName");
00569     objj_msgSend(aCoder, "encodeObject:forKey:", self._groups, "_groups");
00570     objj_msgSend(aCoder, "encodeObject:forKey:", self._nickname, "_nickname");
00571     objj_msgSend(aCoder, "encodeObject:forKey:", self._XMPPStatus, "_XMPPStatus");
00572     objj_msgSend(aCoder, "encodeObject:forKey:", self._XMPPShow, "_XMPPShow");
00573     objj_msgSend(aCoder, "encodeObject:forKey:", self._type, "_type");
00574     objj_msgSend(aCoder, "encodeObject:forKey:", self._statusIcon, "_statusIcon");
00575     objj_msgSend(aCoder, "encodeObject:forKey:", self._messagesQueue, "_messagesQueue");
00576     objj_msgSend(aCoder, "encodeObject:forKey:", self._numberOfEvents, "_numberOfEvents");
00577     if (self._resources)
00578         objj_msgSend(aCoder, "encodeObject:forKey:", self._resources, "_resources");
00579     if (self._vCard)
00580         objj_msgSend(aCoder, "encodeObject:forKey:", self._vCard, "_vCard");
00581 }
00582 ,["void","CPCoder"])]);
00583 }
 All Classes Namespaces Files Functions Variables