StropheCappuccino API 1.0.0
/tmp/tempDoc.doc/Build/StropheCappuccino.build/Debug/Browser.environment/Sources/MUC/TNStropheMUCRoom.j
Go to the documentation of this file.
00001 @STATIC;1.0;I;23;Foundation/Foundation.ji;24;../TNStropheConnection.ji;17;../TNStropheJID.ji;20;../TNStropheStanza.ji;19;../TNStropheUtils.ji;20;TNStropheMUCRoster.jt;9632;objj_executeFile("Foundation/Foundation.j", NO);
00002 objj_executeFile("../TNStropheConnection.j", YES);
00003 objj_executeFile("../TNStropheJID.j", YES);
00004 objj_executeFile("../TNStropheStanza.j", YES);
00005 objj_executeFile("../TNStropheUtils.j", YES);
00006 objj_executeFile("TNStropheMUCRoster.j", YES);
00007 TNStropheMUCConversationWasUpdatedNotification = "TNStropheMUCConversationWasUpdatedNotification";
00008 TNStropheMUCDataReceivedNotification = "TNStropheMUCDataReceivedNotification";
00009 TNStropheMUCPrivateMessageWasReceivedNotification = "TNStropheMUCPrivateMessageWasReceivedNotification";
00010 TNStropheMUCRosterWasUpdatedNotification = "TNStropheMUCRosterWasUpdatedNotification";
00011 TNStropheMUCSubjectWasUpdatedNotification = "TNStropheMUCSubjectWasUpdatedNotification";
00012 {var the_class = objj_allocateClassPair(CPObject, "TNStropheMUCRoom"),
00013 meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_messages"), new objj_ivar("_subject"), new objj_ivar("_delegate"), new objj_ivar("_roomJID"), new objj_ivar("_roster"), new objj_ivar("_handlerIDs"), new objj_ivar("_connection")]);//#pragma mark -
00014 //#pragma mark Initialization
00015 
00016 
00017 //#pragma mark -
00018 //#pragma mark Membership
00019 
00020 
00021 
00022 //#pragma mark -
00023 //#pragma mark Content
00024 
00025 
00026 
00027 
00028 objj_registerClassPair(the_class);
00029 class_addMethods(the_class, [new objj_method(sel_getUid("messages"), function $TNStropheMUCRoom__messages(self, _cmd)
00030 {
00031 return self._messages;
00032 }
00033 ,["CPArray"]), new objj_method(sel_getUid("_setMessages:"), function $TNStropheMUCRoom___setMessages_(self, _cmd, newValue)
00034 {
00035 self._messages = newValue;
00036 }
00037 ,["void","CPArray"]), new objj_method(sel_getUid("subject"), function $TNStropheMUCRoom__subject(self, _cmd)
00038 {
00039 return self._subject;
00040 }
00041 ,["CPString"]), new objj_method(sel_getUid("_setSubject:"), function $TNStropheMUCRoom___setSubject_(self, _cmd, newValue)
00042 {
00043 self._subject = newValue;
00044 }
00045 ,["void","CPString"]), new objj_method(sel_getUid("delegate"), function $TNStropheMUCRoom__delegate(self, _cmd)
00046 {
00047 return self._delegate;
00048 }
00049 ,["id"]), new objj_method(sel_getUid("setDelegate:"), function $TNStropheMUCRoom__setDelegate_(self, _cmd, newValue)
00050 {
00051 self._delegate = newValue;
00052 }
00053 ,["void","id"]), new objj_method(sel_getUid("roomJID"), function $TNStropheMUCRoom__roomJID(self, _cmd)
00054 {
00055 return self._roomJID;
00056 }
00057 ,["TNStropheJID"]), new objj_method(sel_getUid("_setRoomJID:"), function $TNStropheMUCRoom___setRoomJID_(self, _cmd, newValue)
00058 {
00059 self._roomJID = newValue;
00060 }
00061 ,["void","TNStropheJID"]), new objj_method(sel_getUid("roster"), function $TNStropheMUCRoom__roster(self, _cmd)
00062 {
00063 return self._roster;
00064 }
00065 ,["TNStropheMUCRoster"]), new objj_method(sel_getUid("_setRoster:"), function $TNStropheMUCRoom___setRoster_(self, _cmd, newValue)
00066 {
00067 self._roster = newValue;
00068 }
00069 ,["void","TNStropheMUCRoster"]), new objj_method(sel_getUid("initWithRoom:onService:usingConnection:withNick:"), function $TNStropheMUCRoom__initWithRoom_onService_usingConnection_withNick_(self, _cmd, aRoom, aService, aConnection, aNick)
00070 {
00071     if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("TNStropheMUCRoom").super_class }, "init"))
00072     {
00073         self._connection = aConnection;
00074         self._roomJID = objj_msgSend(TNStropheJID, "stropheJIDWithNode:domain:resource:", aRoom, aService, aNick);
00075         self._handlerIDs = objj_msgSend(CPArray, "array");
00076         self._messages = objj_msgSend(CPArray, "array");
00077         self._roster = objj_msgSend(TNStropheMUCRoster, "rosterWithConnection:forRoom:", self._connection, self);
00078     }
00079     return self;
00080 }
00081 ,["id","CPString","CPString","TNStropheConnection","CPString"]), new objj_method(sel_getUid("directedPresence"), function $TNStropheMUCRoom__directedPresence(self, _cmd)
00082 {
00083     return objj_msgSend(TNStropheStanza, "presenceTo:", self._roomJID);
00084 }
00085 ,["TNStropheStanza"]), new objj_method(sel_getUid("join"), function $TNStropheMUCRoom__join(self, _cmd)
00086 {
00087     var messageParams = objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", "message", "name", objj_msgSend(self._roomJID, "full"), "from", "groupchat", "type", {matchBare: true}, "options"),
00088         messageHandler = objj_msgSend(self._connection, "registerSelector:ofObject:withDict:", sel_getUid("receiveMessage:"), self, messageParams);
00089     objj_msgSend(self._handlerIDs, "addObject:", messageHandler);
00090     var pmParams = objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", "message", "name", objj_msgSend(self._roomJID, "full"), "from", "chat", "type", {matchBare: true}, "options"),
00091         pmHandler = objj_msgSend(self._connection, "registerSelector:ofObject:withDict:", sel_getUid("receivePrivateMessage:"), self, pmParams);
00092     objj_msgSend(self._handlerIDs, "addObject:", pmHandler);
00093     objj_msgSend(self._connection, "send:", objj_msgSend(self, "directedPresence"));
00094 }
00095 ,["void"]), new objj_method(sel_getUid("leave"), function $TNStropheMUCRoom__leave(self, _cmd)
00096 {
00097     var leavePresence = objj_msgSend(self, "directedPresence");
00098     objj_msgSend(leavePresence, "setType:", "unavailable");
00099     objj_msgSend(self._connection, "send:", leavePresence);
00100     for (var i = 0; i < objj_msgSend(self._handlerIDs, "count"); i++)
00101         objj_msgSend(self._connection, "deleteRegisteredSelector:", objj_msgSend(self._handlerIDs, "objectAtIndex:", i));
00102 }
00103 ,["void"]), new objj_method(sel_getUid("setSubject:"), function $TNStropheMUCRoom__setSubject_(self, _cmd, aSubject)
00104 {
00105     var message = objj_msgSend(TNStropheStanza, "message");
00106     objj_msgSend(message, "setType:", "groupchat");
00107     objj_msgSend(message, "addChildWithName:", "subject");
00108     objj_msgSend(message, "addTextNode:", aSubject);
00109     objj_msgSend(self, "sendStanzaToRoom:", message);
00110 }
00111 ,["void","CPString"]), new objj_method(sel_getUid("sayToRoom:"), function $TNStropheMUCRoom__sayToRoom_(self, _cmd, aMessage)
00112 {
00113     var message = objj_msgSend(TNStropheStanza, "message");
00114     objj_msgSend(message, "setType:", "groupchat");
00115     objj_msgSend(message, "addChildWithName:", "body");
00116     objj_msgSend(message, "addTextNode:", aMessage);
00117     objj_msgSend(self, "sendStanzaToRoom:", message);
00118 }
00119 ,["void","CPString"]), new objj_method(sel_getUid("sendStanzaToRoom:"), function $TNStropheMUCRoom__sendStanzaToRoom_(self, _cmd, aStanza)
00120 {
00121     objj_msgSend(aStanza, "setTo:", objj_msgSend(self._roomJID, "bare"));
00122     objj_msgSend(self._connection, "send:", aStanza);
00123 }
00124 ,["void","TNStropheStanza"]), new objj_method(sel_getUid("receiveMessage:"), function $TNStropheMUCRoom__receiveMessage_(self, _cmd, aStanza)
00125 {
00126     if (objj_msgSend(aStanza, "containsChildrenWithName:", "subject"))
00127     {
00128         self._subject = objj_msgSend(objj_msgSend(aStanza, "firstChildWithName:", "subject"), "text");
00129         if (self._delegate && objj_msgSend(self._delegate, "respondsToSelector:", sel_getUid("mucRoom:receivedNewSubject:")))
00130             objj_msgSend(self._delegate, "mucRoom:receivedNewSubject:", self, self._subject);
00131         objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:userInfo:", TNStropheMUCSubjectWasUpdatedNotification, self, aStanza);
00132     }
00133     if (objj_msgSend(aStanza, "containsChildrenWithName:", "body"))
00134     {
00135         var body = objj_msgSend(objj_msgSend(aStanza, "firstChildWithName:", "body"), "text"),
00136             contact = objj_msgSend(self._roster, "contactWithJID:", objj_msgSend(aStanza, "from"));
00137         if (!contact)
00138         {
00139             objj_msgSend(self._roster, "addContact:withName:inGroup:", objj_msgSend(aStanza, "from"), objj_msgSend(objj_msgSend(aStanza, "from"), "resource"), objj_msgSend(self._roster, "visitors"));
00140             contact = objj_msgSend(self._roster, "contactWithJID:", objj_msgSend(aStanza, "from"));
00141         }
00142         var message = objj_msgSend(CPDictionary, "dictionaryWithObjectsAndKeys:", body, "body", contact, "from", objj_msgSend(aStanza, "delayTime"), "time");
00143         objj_msgSend(self._messages, "addObject:", message);
00144         if (self._delegate && objj_msgSend(self._delegate, "respondsToSelector:", sel_getUid("mucRoom:receivedMessage:")))
00145             objj_msgSend(self._delegate, "mucRoom:receivedMessage:", self, message);
00146         objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:userInfo:", TNStropheMUCConversationWasUpdatedNotification, self, aStanza);
00147     }
00148     var otherChildren = objj_msgSend(aStanza, "children");
00149     objj_msgSend(otherChildren, "removeObjectsInArray:", objj_msgSend(aStanza, "childrenWithName:", "body"));
00150     objj_msgSend(otherChildren, "removeObjectsInArray:", objj_msgSend(aStanza, "childrenWithName:", "subject"));
00151     if (objj_msgSend(otherChildren, "count") > 0)
00152     {
00153         if (self._delegate && objj_msgSend(self._delegate, "respondsToSelector:", sel_getUid("mucRoom:receivedData:")))
00154             objj_msgSend(self._delegate, "mucRoom:receivedData:", self, aStanza);
00155         objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:userInfo:", TNStropheMUCDataReceivedNotification, self, aStanza);
00156     }
00157     return YES;
00158 }
00159 ,["BOOL","TNStropheStanza"]), new objj_method(sel_getUid("receivePrivateMessage:"), function $TNStropheMUCRoom__receivePrivateMessage_(self, _cmd, aMessage)
00160 {
00161     return YES;
00162 }
00163 ,["BOOL","TNStropheStanza"])]);
00164 class_addMethods(meta_class, [new objj_method(sel_getUid("joinRoom:onService:usingConnection:withNick:"), function $TNStropheMUCRoom__joinRoom_onService_usingConnection_withNick_(self, _cmd, aRoom, aService, aConnection, aNick)
00165 {
00166     return objj_msgSend(objj_msgSend(TNStropheMUCRoom, "alloc"), "initWithRoom:onService:usingConnection:withNick:", aRoom, aService, aConnection, aNick);
00167 }
00168 ,["TNStropheMUCRoom","CPString","CPString","TNStropheConnection","CPString"])]);
00169 }
 All Classes Namespaces Files Functions Variables