StropheCappuccino API 1.0.0
/tmp/tempDoc.doc/Build/StropheCappuccino.build/Debug/CommonJS.environment/Sources/TNStropheGroup.j
Go to the documentation of this file.
00001 @STATIC;1.0;I;23;Foundation/Foundation.jt;7759;objj_executeFile("Foundation/Foundation.j", NO);
00002 //@global TNStropheRosterRosterDelimiter
00003 TNStropheGroupRemovedNotification = "TNStropheGroupRemoved";
00004 {var the_class = objj_allocateClassPair(CPObject, "TNStropheGroup"),
00005 meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_subGroups"), new objj_ivar("_contacts"), new objj_ivar("_name"), new objj_ivar("_parentGroup")]);//#pragma mark -
00006 //#pragma mark Initialization
00007 
00008 
00009 //#pragma mark -
00010 //#pragma mark Overides
00011 
00012 //#pragma mark -
00013 //#pragma mark Contacts
00014 
00015 //#pragma mark -
00016 //#pragma mark Subgroups
00017 
00018 
00019 
00020 
00021 
00022 //#pragma mark -
00023 //#pragma mark Counting
00024 
00025 
00026 
00027 
00028 objj_registerClassPair(the_class);
00029 class_addMethods(the_class, [new objj_method(sel_getUid("subGroups"), function $TNStropheGroup__subGroups(self, _cmd)
00030 {
00031 return self._subGroups;
00032 }
00033 ,["CPArray"]), new objj_method(sel_getUid("_setSubGroups:"), function $TNStropheGroup___setSubGroups_(self, _cmd, newValue)
00034 {
00035 self._subGroups = newValue;
00036 }
00037 ,["void","CPArray"]), new objj_method(sel_getUid("contacts"), function $TNStropheGroup__contacts(self, _cmd)
00038 {
00039 return self._contacts;
00040 }
00041 ,["CPArray"]), new objj_method(sel_getUid("setContacts:"), function $TNStropheGroup__setContacts_(self, _cmd, newValue)
00042 {
00043 self._contacts = newValue;
00044 }
00045 ,["void","CPArray"]), new objj_method(sel_getUid("name"), function $TNStropheGroup__name(self, _cmd)
00046 {
00047 return self._name;
00048 }
00049 ,["CPString"]), new objj_method(sel_getUid("setName:"), function $TNStropheGroup__setName_(self, _cmd, newValue)
00050 {
00051 self._name = newValue;
00052 }
00053 ,["void","CPString"]), new objj_method(sel_getUid("parentGroup"), function $TNStropheGroup__parentGroup(self, _cmd)
00054 {
00055 return self._parentGroup;
00056 }
00057 ,["TNStropheGroup"]), new objj_method(sel_getUid("setParentGroup:"), function $TNStropheGroup__setParentGroup_(self, _cmd, newValue)
00058 {
00059 self._parentGroup = newValue;
00060 }
00061 ,["void","TNStropheGroup"]), new objj_method(sel_getUid("initWithName:"), function $TNStropheGroup__initWithName_(self, _cmd, aName)
00062 {
00063     if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("TNStropheGroup").super_class }, "init"))
00064     {
00065         self._contacts = objj_msgSend(CPArray, "array");
00066         self._subGroups = objj_msgSend(CPArray, "array");
00067         self._name = aName;
00068         self._parentGroup = nil;
00069     }
00070     return self;
00071 }
00072 ,["TNStropheGroup","CPString"]), new objj_method(sel_getUid("description"), function $TNStropheGroup__description(self, _cmd)
00073 {
00074     return self._name;
00075 }
00076 ,["CPString"]), new objj_method(sel_getUid("contactWithJID:matchBare:"), function $TNStropheGroup__contactWithJID_matchBare_(self, _cmd, aJID, matchBare)
00077 {
00078     for (var i = 0; i < objj_msgSend(self._contacts, "count"); i++)
00079     {
00080         if (matchBare)
00081         {
00082             if (objj_msgSend(objj_msgSend(objj_msgSend(self._contacts, "objectAtIndex:", i), "JID"), "bareEquals:", aJID))
00083                 return objj_msgSend(self._contacts, "objectAtIndex:", i);
00084         }
00085         else
00086         {
00087             if (objj_msgSend(objj_msgSend(objj_msgSend(self._contacts, "objectAtIndex:", i), "JID"), "fullEquals:", aJID))
00088                 return objj_msgSend(self._contacts, "objectAtIndex:", i);
00089         }
00090     }
00091     return nil;
00092 }
00093 ,["TNStropheContact","TNStropheJID","BOOL"]), new objj_method(sel_getUid("addSubGroup:"), function $TNStropheGroup__addSubGroup_(self, _cmd, aGroup)
00094 {
00095     if (!objj_msgSend(aGroup, "isKindOfClass:", TNStropheGroup))
00096         objj_msgSend(CPException, "raise:reason:", "Invalid Object", "addSubGroup only supports to add TNStropheGroups");
00097     objj_msgSend(aGroup, "setParentGroup:", self);
00098     objj_msgSend(self._subGroups, "addObject:", aGroup);
00099 }
00100 ,["void","TNStropheGroup"]), new objj_method(sel_getUid("removeSubGroup:"), function $TNStropheGroup__removeSubGroup_(self, _cmd, aGroup)
00101 {
00102     if (!objj_msgSend(self._subGroups, "containsObject:", aGroup))
00103         return;
00104     objj_msgSend(aGroup, "setParentGroup:", nil);
00105     objj_msgSend(self._subGroups, "removeObject:", aGroup);
00106 }
00107 ,["void","TNStropheGroup"]), new objj_method(sel_getUid("removeSubGroups"), function $TNStropheGroup__removeSubGroups(self, _cmd)
00108 {
00109     for (var i = 0; i < objj_msgSend(self, "subGroupsCount"); i++)
00110     {
00111         var subGroup = objj_msgSend(self._subGroups, "objectAtIndex:", i);
00112         objj_msgSend(self, "removeSubGroup:", subGroup);
00113     }
00114     objj_msgSend(self._subGroups, "removeAllObjects");
00115 }
00116 ,["void"]), new objj_method(sel_getUid("subGroupWithName:"), function $TNStropheGroup__subGroupWithName_(self, _cmd, aName)
00117 {
00118     for (var i = 0; i < objj_msgSend(self, "subGroupsCount"); i++)
00119         if (objj_msgSend(objj_msgSend(objj_msgSend(self._subGroups, "objectAtIndex:", i), "name"), "uppercaseString") == objj_msgSend(aName, "uppercaseString"))
00120             return objj_msgSend(self._subGroups, "objectAtIndex:", i);
00121     return nil;
00122 }
00123 ,["TNStropheGroup","CPString"]), new objj_method(sel_getUid("path"), function $TNStropheGroup__path(self, _cmd)
00124 {
00125     var path = [objj_msgSend(self, "name")],
00126         currentGroup = self;
00127     while (currentGroup)
00128     {
00129         currentGroup = objj_msgSend(currentGroup, "parentGroup");
00130         if (currentGroup)
00131             objj_msgSend(path, "addObject:", objj_msgSend(objj_msgSend(currentGroup, "name"), "uppercaseString"));
00132     }
00133     return path.reverse().join(TNStropheRosterRosterDelimiter);
00134 }
00135 ,["CPString"]), new objj_method(sel_getUid("flush"), function $TNStropheGroup__flush(self, _cmd)
00136 {
00137     objj_msgSend(self, "removeSubGroups");
00138     objj_msgSend(self._contacts, "removeAllObjects");
00139 }
00140 ,["void"]), new objj_method(sel_getUid("subGroupsCount"), function $TNStropheGroup__subGroupsCount(self, _cmd)
00141 {
00142     return objj_msgSend(self._subGroups, "count");
00143 }
00144 ,["int"]), new objj_method(sel_getUid("contactCount"), function $TNStropheGroup__contactCount(self, _cmd)
00145 {
00146     return objj_msgSend(self._contacts, "count");
00147 }
00148 ,["int"]), new objj_method(sel_getUid("count"), function $TNStropheGroup__count(self, _cmd)
00149 {
00150     return objj_msgSend(self, "subGroupsCount") + objj_msgSend(self, "contactCount");
00151 }
00152 ,["int"]), new objj_method(sel_getUid("content"), function $TNStropheGroup__content(self, _cmd)
00153 {
00154     return objj_msgSend(self._subGroups.sort(), "arrayByAddingObjectsFromArray:", self._contacts.sort());
00155 }
00156 ,["CPArray"])]);
00157 class_addMethods(meta_class, [new objj_method(sel_getUid("stropheGroupWithName:"), function $TNStropheGroup__stropheGroupWithName_(self, _cmd, aName)
00158 {
00159     return objj_msgSend(objj_msgSend(TNStropheGroup, "alloc"), "initWithName:", aName);
00160 }
00161 ,["TNStropheGroup","CPString"])]);
00162 }
00163 {
00164 var the_class = objj_getClass("TNStropheGroup")
00165 if(!the_class) throw new SyntaxError("*** Could not find definition for class \"TNStropheGroup\"");
00166 var meta_class = the_class.isa;
00167 class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $TNStropheGroup__initWithCoder_(self, _cmd, aCoder)
00168 {
00169     if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("TNStropheGroup").super_class }, "init"))
00170     {
00171         self._contacts = objj_msgSend(aCoder, "decodeObjectForKey:", "_contacts");
00172         self._name = objj_msgSend(aCoder, "decodeObjectForKey:", "_name");
00173         self._parentGroup = objj_msgSend(aCoder, "decodeObjectForKey:", "_parentGroup");
00174         self._subGroups = objj_msgSend(aCoder, "decodeObjectForKey:", "_subGroups");
00175     }
00176     return self;
00177 }
00178 ,["id","CPCoder"]), new objj_method(sel_getUid("encodeWithCoder:"), function $TNStropheGroup__encodeWithCoder_(self, _cmd, aCoder)
00179 {
00180     objj_msgSend(aCoder, "encodeObject:forKey:", self._contacts, "_contacts");
00181     objj_msgSend(aCoder, "encodeObject:forKey:", self._name, "_name");
00182     objj_msgSend(aCoder, "encodeObject:forKey:", self._parentGroup, "_parentGroup");
00183     objj_msgSend(aCoder, "encodeObject:forKey:", self._subGroups, "_subGroups");
00184 }
00185 ,["void","CPCoder"])]);
00186 }
 All Classes Namespaces Files Functions Variables