StropheCappuccino API 1.0.0
/tmp/tempDoc.doc/TNStropheVCard.j
Go to the documentation of this file.
00001 /*
00002  * TNStropheVCard.j
00003  *
00004  * Copyright (C) 2010 Antoine Mercadal <antoine.mercadal@inframonde.eu>
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU Affero General Public License as
00007  * published by the Free Software Foundation, either version 3 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU Affero General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Affero General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 
00020 
00021 
00022 @implementation TNStropheVCard : CPObject
00023 {
00024     CPImage     _photo;
00025     CPString    _categories;
00026     CPString    _fullName;
00027     CPString    _locality;
00028     CPString    _organizationName;
00029     CPString    _organizationUnit;
00030     CPString    _role;
00031     CPString    _title;
00032     CPString    _type;
00033     CPString    _userID;
00034 }
00035 
00036 
00037 #pragma mark -
00038 #pragma mark Initialization
00039 
00040 - (id)initWithXMLNode:(TNXMLNode)aNode
00041 {
00042     if (self = [super init])
00043     {
00044         _categories       = [[aNode firstChildWithName:@"CATEGORIES"] text];
00045         _fullName         = [[aNode firstChildWithName:@"FN"] text];
00046         _locality         = [[aNode firstChildWithName:@"LOCALITY"] text];
00047         _organizationName = [[aNode firstChildWithName:@"ORGNAME"] text];
00048         _organizationUnit = [[aNode firstChildWithName:@"ORGUNIT"] text];
00049         _role             = [[aNode firstChildWithName:@"ROLE"] text];
00050         _title            = [[aNode firstChildWithName:@"TITLE"] text];
00051         _type             = [[aNode firstChildWithName:@"TYPE"] text];
00052         _userID           = [[aNode firstChildWithName:@"USERID"] text];
00053 
00054         var photoNode;
00055         if (photoNode = [aNode firstChildWithName:@"PHOTO"])
00056         {
00057             var data = [[photoNode firstChildWithName:@"BINVAL"] text];
00058             _photo = [[CPImage alloc] initWithData:[CPData dataWithBase64:data]];
00059         }
00060     }
00061 
00062     return self;
00063 }
00064 
00065 
00066 #pragma mark -
00067 #pragma mark VCard generation
00068 
00069 - (TNXMLNode)XMLNode
00070 {
00071     var node = [TNXMLNode nodeWithName:@"vCard" andAttributes:{@"xmlns": @"vcard-temp"}];
00072 
00073     if (_fullName)
00074     {
00075         [node addChildWithName:@"FN"];
00076         [node addTextNode:_fullName];
00077         [node up];
00078     }
00079     if (_title)
00080     {
00081         [node addChildWithName:@"TITLE"];
00082         [node addTextNode:_title];
00083         [node up];
00084     }
00085     if (_organizationName)
00086     {
00087         [node addChildWithName:@"ORGNAME"];
00088         [node addTextNode:_organizationName];
00089         [node up];
00090     }
00091     if (_organizationUnit)
00092     {
00093         [node addChildWithName:@"ORGUNIT"];
00094         [node addTextNode:_organizationUnit];
00095         [node up];
00096     }
00097     if (_userID)
00098     {
00099         [node addChildWithName:@"USERID"];
00100         [node addTextNode:_userID];
00101         [node up];
00102     }
00103     if (_locality)
00104     {
00105         [node addChildWithName:@"LOCALITY"];
00106         [node addTextNode:_locality];
00107         [node up];
00108     }
00109     if (_categories)
00110     {
00111         [node addChildWithName:@"CATEGORIES"];
00112         [node addTextNode:_categories];
00113         [node up];
00114     }
00115     if (_type)
00116     {
00117         [node addChildWithName:@"TYPE"];
00118         [node addTextNode:_type];
00119         [node up];
00120     }
00121     if (_role)
00122     {
00123         [node addChildWithName:@"ROLE"];
00124         [node addTextNode:_role];
00125         [node up];
00126     }
00127 
00128     if (_photo)
00129     {
00130         [node addChildWithName:@"PHOTO"];
00131         [node addChildWithName:@"BINVAL"];
00132         [node addTextNode:[[_photo data] base64]];
00133         [node up];
00134         [node up];
00135     }
00136 
00137     return node;
00138 }
00139 
00140 @end
00141 
00142 
00143 @implementation TNStropheVCard (CPCoding)
00144 
00145 - (id)initWithCoder:(CPCoder)aCoder
00146 {
00147     if (self = [super init])
00148     {
00149          _fullName         = [aCoder decodeObjectForKey:@"_fullName"];
00150          _organizationName = [aCoder decodeObjectForKey:@"_organizationName"];
00151          _organizationUnit = [aCoder decodeObjectForKey:@"_organizationUnit"];
00152          _userID           = [aCoder decodeObjectForKey:@"_userID"];
00153          _locality         = [aCoder decodeObjectForKey:@"_locality"];
00154          _categories       = [aCoder decodeObjectForKey:@"_categories"];
00155          _type             = [aCoder decodeObjectForKey:@"_type"];
00156          _role             = [aCoder decodeObjectForKey:@"_role"];
00157          _title            = [aCoder decodeObjectForKey:@"_title"];
00158          _photo            = [aCoder decodeObjectForKey:@"_photo"];
00159     }
00160 
00161     return self;
00162 }
00163 
00164 - (void)encodeWithCoder:(CPCoder)aCoder
00165 {
00166     [aCoder encodeObject:_fullName forKey:@"_fullName"];
00167     [aCoder encodeObject:_organizationName forKey:@"_organizationName"];
00168     [aCoder encodeObject:_organizationUnit forKey:@"_organizationUnit"];
00169     [aCoder encodeObject:_userID forKey:@"_userID"];
00170     [aCoder encodeObject:_locality forKey:@"_locality"];
00171     [aCoder encodeObject:_categories forKey:@"_categories"];
00172     [aCoder encodeObject:_type forKey:@"_type"];
00173     [aCoder encodeObject:_role forKey:@"_role"];
00174     [aCoder encodeObject:_title forKey:@"_title"];
00175     [aCoder encodeObject:_photo forKey:@"_photo"];
00176 }
00177 
00178 @end
00179 
00180 @implementation TNStropheVCard (CPSynthesizedAccessors)
00181 
00185 - (CPImage)photo
00186 {
00187     return _photo;
00188 }
00189 
00193 - (void)setPhoto:(CPImage)aValue
00194 {
00195     _photo = aValue;
00196 }
00197 
00201 - (CPString)categories
00202 {
00203     return _categories;
00204 }
00205 
00209 - (void)setCategories:(CPString)aValue
00210 {
00211     _categories = aValue;
00212 }
00213 
00217 - (CPString)fullName
00218 {
00219     return _fullName;
00220 }
00221 
00225 - (void)setFullName:(CPString)aValue
00226 {
00227     _fullName = aValue;
00228 }
00229 
00233 - (CPString)locality
00234 {
00235     return _locality;
00236 }
00237 
00241 - (void)setLocality:(CPString)aValue
00242 {
00243     _locality = aValue;
00244 }
00245 
00249 - (CPString)organizationName
00250 {
00251     return _organizationName;
00252 }
00253 
00257 - (void)setOrganizationName:(CPString)aValue
00258 {
00259     _organizationName = aValue;
00260 }
00261 
00265 - (CPString)organizationUnit
00266 {
00267     return _organizationUnit;
00268 }
00269 
00273 - (void)setOrganizationUnit:(CPString)aValue
00274 {
00275     _organizationUnit = aValue;
00276 }
00277 
00281 - (CPString)role
00282 {
00283     return _role;
00284 }
00285 
00289 - (void)setRole:(CPString)aValue
00290 {
00291     _role = aValue;
00292 }
00293 
00297 - (CPString)title
00298 {
00299     return _title;
00300 }
00301 
00305 - (void)setTitle:(CPString)aValue
00306 {
00307     _title = aValue;
00308 }
00309 
00313 - (CPString)type
00314 {
00315     return _type;
00316 }
00317 
00321 - (void)setType:(CPString)aValue
00322 {
00323     _type = aValue;
00324 }
00325 
00329 - (CPString)userID
00330 {
00331     return _userID;
00332 }
00333 
00337 - (void)setUserID:(CPString)aValue
00338 {
00339     _userID = aValue;
00340 }
00341 
00342 @end
 All Classes Namespaces Files Functions Variables