|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : AddressBookContact.cpp 00004 * Part of : AddressBook 00005 * Interface : 00006 * Description : CAddressBookContact class - 00007 * responsible for work with personal card of an employee, 00008 * who was found 00009 * Version : 00010 * 00011 * Copyright (c) 2002-2006 Nokia Corporation. 00012 * This material, including documentation and any related 00013 * computer programs, is protected by copyright controlled by 00014 * Nokia Corporation. 00015 * ============================================================================== 00016 */ 00017 00018 // INCLUDES 00019 #include "AddressBookContact.h" 00020 #include <SenBaseAttribute.h> 00021 00022 // ================= MEMBER FUNCTIONS ======================= 00023 00024 // ---------------------------------------------------------------------------- 00025 // CAddressBookContact::CAddressBookContact() 00026 // ---------------------------------------------------------------------------- 00027 // 00028 CAddressBookContact::CAddressBookContact() 00029 { 00030 } 00031 00032 // ---------------------------------------------------------------------------- 00033 // CAddressBookContact::NewL() 00034 // Two-phased constructor 00035 // ---------------------------------------------------------------------------- 00036 // 00037 CAddressBookContact* CAddressBookContact::NewL() 00038 { 00039 CAddressBookContact* pNew = new (ELeave) CAddressBookContact(); 00040 CleanupStack::PushL(pNew); 00041 pNew->ConstructL(); 00042 CleanupStack::Pop(pNew); 00043 return pNew; 00044 } 00045 00046 // ---------------------------------------------------------------------------- 00047 // CAddressBookContact::ConstructL() 00048 // ---------------------------------------------------------------------------- 00049 // 00050 void CAddressBookContact::ConstructL() 00051 { 00052 CSenDomFragment::BaseConstructL(KNsUri, KElementNameCard, KQualifiedNameCard); 00053 } 00054 00055 // ---------------------------------------------------------------------------- 00056 // CAddressBookContact::FirstName() 00057 // The function gets first name of the person who was found 00058 // ---------------------------------------------------------------------------- 00059 // 00060 const TPtrC8 CAddressBookContact::FirstName() 00061 { 00062 return ChildValue(KElementNameN, KElementNameGiven); 00063 } 00064 00065 // ---------------------------------------------------------------------------- 00066 // CAddressBookContact::LastName() 00067 // The function gets last name of the person who was found 00068 // ---------------------------------------------------------------------------- 00069 // 00070 const TPtrC8 CAddressBookContact::LastName() 00071 { 00072 return ChildValue(KElementNameN, KElementNameFamily); 00073 } 00074 00075 // ---------------------------------------------------------------------------- 00076 // CAddressBookContact::Street() 00077 // The function gets a street where the person who was found lives 00078 // ---------------------------------------------------------------------------- 00079 // 00080 const TPtrC8 CAddressBookContact::Street() 00081 { 00082 return ChildValue(KElementNameAdr, KElementNameStreet); 00083 } 00084 00085 // ---------------------------------------------------------------------------- 00086 // CAddressBookContact::PostCode() 00087 // The function gets post code where the person who was found lives 00088 // ---------------------------------------------------------------------------- 00089 // 00090 const TPtrC8 CAddressBookContact::PostCode() 00091 { 00092 return ChildValue(KElementNameAdr, KElementNamePCode); 00093 } 00094 00095 // ---------------------------------------------------------------------------- 00096 // CAddressBookContact::PhoneL() 00097 // The function gets a phone of the person who was found 00098 // ---------------------------------------------------------------------------- 00099 // 00100 const TPtrC8 CAddressBookContact::PhoneL() 00101 { 00102 return SelectedPhoneL(KElementNamePref); 00103 } 00104 00105 // ---------------------------------------------------------------------------- 00106 // CAddressBookContact::MobilePhoneL() 00107 // The function gets mobile phone of the person who was found 00108 // ---------------------------------------------------------------------------- 00109 // 00110 const TPtrC8 CAddressBookContact::MobilePhoneL() 00111 { 00112 return SelectedPhoneL(KElementNameCell); 00113 } 00114 00115 // ---------------------------------------------------------------------------- 00116 // CAddressBookContact::Email() 00117 // The function gets email of the person who was found 00118 // ---------------------------------------------------------------------------- 00119 // 00120 const TPtrC8 CAddressBookContact::Email() 00121 { 00122 return ContentOf(KElementNameEmail); 00123 } 00124 00125 // ---------------------------------------------------------------------------- 00126 // CAddressBookContact::MiddleName() 00127 // The function gets middle name of the person who was found 00128 // ---------------------------------------------------------------------------- 00129 // 00130 const TPtrC8 CAddressBookContact::MiddleName() 00131 { 00132 return ChildValue(KElementNameN, KElementNameMiddle); 00133 } 00134 00135 // ---------------------------------------------------------------------------- 00136 // CAddressBookContact::ExtraAddress() 00137 // The function gets additional address where the person who was found lives 00138 // ---------------------------------------------------------------------------- 00139 // 00140 const TPtrC8 CAddressBookContact::ExtraAddress() 00141 { 00142 return ChildValue(KElementNameAdr, KElementNameExtAdr); 00143 } 00144 00145 // ---------------------------------------------------------------------------- 00146 // CAddressBookContact::Locality() 00147 // The function gets locality where the person who was found lives 00148 // ---------------------------------------------------------------------------- 00149 // 00150 const TPtrC8 CAddressBookContact::Locality() 00151 { 00152 return ChildValue(KElementNameAdr, KElementNameLocality); 00153 } 00154 00155 // ---------------------------------------------------------------------------- 00156 // CAddressBookContact::Region() 00157 // The function gets a region where the person who was found lives 00158 // ---------------------------------------------------------------------------- 00159 // 00160 const TPtrC8 CAddressBookContact::Region() 00161 { 00162 return ChildValue(KElementNameAdr, KElementNameRegion); 00163 } 00164 00165 // ---------------------------------------------------------------------------- 00166 // CAddressBookContact::Country() 00167 // The function gets a country where the person who was found lives 00168 // ---------------------------------------------------------------------------- 00169 // 00170 const TPtrC8 CAddressBookContact::Country() 00171 { 00172 return ChildValue(KElementNameAdr, KElementNameCountry); 00173 } 00174 00175 // ---------------------------------------------------------------------------- 00176 // CAddressBookContact::FaxL() 00177 // The function gets a fax of the person who was found 00178 // ---------------------------------------------------------------------------- 00179 // 00180 const TPtrC8 CAddressBookContact::FaxL() 00181 { 00182 return SelectedPhoneL(KElementNameFax); 00183 } 00184 00185 // ---------------------------------------------------------------------------- 00186 // CAddressBookContact::Title() 00187 // The function gets a title of the person who was found 00188 // ---------------------------------------------------------------------------- 00189 // 00190 const TPtrC8 CAddressBookContact::Title() 00191 { 00192 return ContentOf(KElementNameTitle); 00193 } 00194 00195 // ---------------------------------------------------------------------------- 00196 // CAddressBookContact::Organization() 00197 // The function gets a name of organization where the person who was found works 00198 // ---------------------------------------------------------------------------- 00199 // 00200 const TPtrC8 CAddressBookContact::Organization() 00201 { 00202 return ChildValue(KElementNameOrg, KElementNameOrgName); 00203 } 00204 00205 // ---------------------------------------------------------------------------- 00206 // CAddressBookContact::Unit() 00207 // The function gets a name of unit where the person who was found works 00208 // ---------------------------------------------------------------------------- 00209 // 00210 const TPtrC8 CAddressBookContact::Unit() 00211 { 00212 return ChildValue(KElementNameOrg, KElementNameOrgUnit); 00213 } 00214 00215 // ---------------------------------------------------------------------------- 00216 // CAddressBookContact::ChildValue(const TDesC8& aFirstElement, 00217 // const TDesC8& aSecondElement) 00218 // The function binds two elements and returns their content 00219 // ---------------------------------------------------------------------------- 00220 // 00221 const TPtrC8 CAddressBookContact::ChildValue(const TDesC8& aFirstElement, 00222 const TDesC8& aSecondElement) 00223 { 00224 CSenElement* pElement = AsElement().Element(aFirstElement); 00225 if (pElement) 00226 { 00227 pElement = pElement->Element(aSecondElement); 00228 if (pElement) 00229 { 00230 return pElement->Content(); 00231 } 00232 } 00233 return KNullDesC8(); 00234 } 00235 00236 // ---------------------------------------------------------------------------- 00237 // CAddressBookContact::SelectedPhoneL(const TDesC8& aType) 00238 // The function check a type of phone (mobile, general, fax) and returns its content 00239 // ---------------------------------------------------------------------------- 00240 // 00241 const TPtrC8 CAddressBookContact::SelectedPhoneL(const TDesC8& aType) 00242 { 00243 RPointerArray<CSenElement> elements = AsElement().ElementsL(); 00244 CSenElement* pElement = NULL; 00245 for (TInt i=0; i<elements.Count(); i++) 00246 { 00247 pElement = elements[i]; 00248 if (pElement->LocalName() == KElementNameTel) 00249 { 00250 const TDesC8* value = pElement->AttrValue(KAttrNameTypeUpperCase); 00251 if (!value) 00252 { 00253 // lower case type check just in case 00254 value = pElement->AttrValue(KAttrNameTypeLowerCase); 00255 } 00256 if (value && *value == aType) 00257 { 00258 return pElement->Content(); 00259 } 00260 } 00261 } 00262 return KNullDesC8(); 00263 } 00264 00265 // End of File 00266
|
© Nokia 2006 |