wincontact.cpp
来自「funambol window mobile客户端源代码」· C++ 代码 · 共 929 行 · 第 1/3 页
CPP
929 行
/*
* Funambol is a mobile platform developed by Funambol, Inc.
* Copyright (C) 2003 - 2007 Funambol, Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by
* the Free Software Foundation with the addition of the following permission
* added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
* WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, see http://www.gnu.org/licenses or write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
*
* You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
* 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
* "Powered by Funambol" logo. If the display of the logo is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display
* the words "Powered by Funambol".
*/
#include "vocl/WinContact.h"
#include "vocl/VConverter.h"
#include "vocl/constants.h"
#include "base/stringUtils.h"
#include "base/globalsdef.h"
USE_NAMESPACE
using namespace std;
// Constructor
WinContact::WinContact() {
vCard = L"";
photoType = L"";
}
// Constructor: fills propertyMap parsing the passed vCard string
WinContact::WinContact(const wstring dataString) {
vCard = L"";
photoType = L"";
parse(dataString);
}
// Destructor
WinContact::~WinContact() {
}
//
// Format and return a vCard string from the propertyMap.
//
wstring& WinContact::toString() {
vCard = L"";
//
// Conversion: WinContact -> vObject.
// ----------------------------------
//
VObject* vo = new VObject();
wstring element;
VProperty* vp = NULL;
bool found = false;
vp = new VProperty(L"BEGIN", L"VCARD");
vo->addProperty(vp);
delete vp; vp = NULL;
vp = new VProperty(L"VERSION", VCARD_VERSION);
vo->addProperty(vp);
delete vp; vp = NULL;
// ------- Name -------
// Add only if at least 1 property is supported, but include
// all elements in the right order.
found = false;
vp = new VProperty(L"N");
if (getProperty(L"LastName", element)) found = true;
vp->addValue(element.c_str());
if (getProperty(L"FirstName", element)) found = true;
vp->addValue(element.c_str());
if (getProperty(L"MiddleName", element)) found = true;
vp->addValue(element.c_str());
if (getProperty(L"Title", element)) found = true;
vp->addValue(element.c_str());
if (getProperty(L"Suffix", element)) found = true;
vp->addValue(element.c_str());
if (found) {
vo->addProperty(vp);
}
delete vp; vp = NULL;
if (getProperty(L"Birthday", element)) {
vp = new VProperty(L"BDAY", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Body", element)) {
vp = new VProperty(L"NOTE", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"BusinessFaxNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"WORK", NULL);
vp->addParameter(L"FAX", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"BusinessTelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"VOICE", NULL);
vp->addParameter(L"WORK", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Business2TelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"VOICE", NULL);
vp->addParameter(L"WORK", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"BusinessWebPage", element)) {
vp = new VProperty(L"URL", element.c_str());
vp->addParameter(L"WORK", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"CarTelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"CAR", NULL);
vp->addParameter(L"VOICE", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Categories", element)) {
vp = new VProperty(L"CATEGORIES", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"CompanyMainTelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"WORK", NULL);
vp->addParameter(L"PREF", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"FileAs", element)) {
vp = new VProperty(L"FN", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
// Mapping is:
// Email1Address <-> EMAIL;INTERNET:
// Email2Address <-> EMAIL;INTERNET;HOME:
// Email3Address <-> EMAIL;INTERNET;WORK:
if (getProperty(L"Email1Address", element)) {
vp = new VProperty(L"EMAIL", element.c_str());
vp->addParameter(L"INTERNET", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Email2Address", element)) {
vp = new VProperty(L"EMAIL", element.c_str());
vp->addParameter(L"INTERNET", NULL);
vp->addParameter(L"HOME", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Email3Address", element)) {
vp = new VProperty(L"EMAIL", element.c_str());
vp->addParameter(L"INTERNET", NULL);
vp->addParameter(L"WORK", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"JobTitle", element)) {
vp = new VProperty(L"TITLE", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"HomeTelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"VOICE", NULL);
vp->addParameter(L"HOME", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Home2TelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"VOICE", NULL);
vp->addParameter(L"HOME", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"HomeFaxNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"HOME", NULL);
vp->addParameter(L"FAX", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"HomeWebPage", element)) {
vp = new VProperty(L"URL", element.c_str());
vp->addParameter(L"HOME", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Importance", element)) {
vp = new VProperty(L"PRIORITY", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"MobileTelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"CELL", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"NickName", element)) {
vp = new VProperty(L"NICKNAME", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"OtherFaxNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"FAX", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"OtherTelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"VOICE", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"PagerNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"PAGER", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"PrimaryTelephoneNumber", element)) {
vp = new VProperty(L"TEL", element.c_str());
vp->addParameter(L"PREF", NULL);
vp->addParameter(L"VOICE", NULL);
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Profession", element)) {
vp = new VProperty(L"ROLE", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"Sensitivity", element)) {
long sensitivity = _wtoi(element.c_str());
vp = new VProperty(TEXT("CLASS"));
if(sensitivity == winPrivate) {
vp->addValue(TEXT("PRIVATE"));
}
else if (sensitivity == winConfidential) {
vp->addValue(TEXT("CONFIDENTIAL"));
}
else { // default value
vp->addValue(TEXT("PUBLIC"));
}
vo->addProperty(vp);
delete vp; vp = NULL;
}
if (getProperty(L"WebPage", element)) {
vp = new VProperty(L"URL", element.c_str());
vo->addProperty(vp);
delete vp; vp = NULL;
}
// ----- ORG -----
// Add only if at least 1 property is supported, but include
// all elements in the right order.
found = false;
vp = new VProperty(L"ORG");
if (getProperty(L"CompanyName", element)) found = true;
vp->addValue(element.c_str());
if (getProperty(L"Department", element)) found = true;
vp->addValue(element.c_str());
if (getProperty(L"OfficeLocation", element)) found = true;
vp->addValue(element.c_str());
if (found) {
vo->addProperty(vp);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?