bool BirthdayProcessed = FALSE;
bool AnniversaryProcessed = FALSE;
bool UIDProcessed = FALSE;
+ bool RevisionProcessed = FALSE;
int ContactLineLen = 0;
int QuoteBreakPoint = 0;
+ int SourceCount = 0;
int GroupCount = 0;
int FNCount = 0;
int NicknameCount = 0;
int KeyCount = 0;
int VendorCount = 0;
int XTokenCount = 0;
+ int XMLCount = 0;
+ int ClientPIDCount = 0;
wxString ContactLine;
wxString PropertyLine;
wxString PropertySeg1;
UIDToken = PropertySeg2;
UIDProcessed = TRUE;
+ } else if (Property == wxT("SOURCE")){
+
+ ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
+ SourceCount++;
+
+ } else if (Property == wxT("XML")){
+
+ ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
+ XMLCount++;
+
+ } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
+
+ ProcessRevision(PropertySeg1, PropertySeg2);
+ RevisionProcessed = TRUE;
+
} else if (Property == wxT("MEMBER")){
ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
ProcessN(PropertySeg1, PropertySeg2);
NameProcessed = TRUE;
+ } else if (Property == wxT("CLIENTPIDMAP")){
+
+ ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
+ ClientPIDCount++;
+
} else if (Property == wxT("NICKNAME")){
ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
}
+void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
+
+ size_t intPropertyLen = PropertySeg1.Len();
+ std::map<int, int> SplitPoints;
+ std::map<int, int> SplitLength;
+ std::map<int, int>::iterator SLiter;
+ wxString PropertyData;
+ wxString PropertyName;
+ wxString PropertyValue;
+ wxString PropertyTokens;
+ bool FirstToken = TRUE;
+ int intSplitsFound = 0;
+ int intSplitSize = 0;
+ int intPrevValue = 5;
+ int intPref = 0;
+ int intType = 0;
+
+ SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
+
+ intPrevValue = 4;
+
+ for (std::map<int, int>::iterator intiter = SplitPoints.begin();
+ intiter != SplitPoints.end(); ++intiter){
+
+ SLiter = SplitLength.find(intiter->first);
+
+ PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
+
+ wxStringTokenizer PropertyElement (PropertyData, wxT("="));
+ PropertyName = PropertyElement.GetNextToken();
+ PropertyValue = PropertyElement.GetNextToken();
+
+ intPrevValue = intiter->second;
+
+ // Process properties.
+
+ size_t intPropertyValueLen = PropertyValue.Len();
+
+ if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
+
+ PropertyValue.Trim();
+ PropertyValue.RemoveLast();
+
+ }
+
+ if (PropertyValue.Mid(0, 1) == wxT("\"")){
+
+ PropertyValue.Remove(0, 1);
+
+ }
+
+ CaptureString(&PropertyValue, FALSE);
+
+ if (FirstToken == TRUE){
+
+ PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+ FirstToken = FALSE;
+
+ } else {
+
+ PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
+
+ }
+
+ }
+
+ CaptureString(&PropertySeg2, FALSE);
+
+ Revision = PropertySeg2;
+
+ if (!PropertyTokens.IsEmpty()){
+
+ RevisionTokens = PropertyTokens;
+
+ }
+
+
+}
+
+void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
+
+ size_t intPropertyLen = PropertySeg1.Len();
+ std::map<int, int> SplitPoints;
+ std::map<int, int> SplitLength;
+ std::map<int, int>::iterator SLiter;
+ wxString PropertyData;
+ wxString PropertyName;
+ wxString PropertyValue;
+ wxString PropertyTokens;
+ bool FirstToken = TRUE;
+ int intSplitsFound = 0;
+ int intSplitSize = 0;
+ int intPrevValue = 8;
+ int intPref = 0;
+ int intType = 0;
+
+ SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
+
+ intPrevValue = 7;
+
+ PropertyType PropType = PROPERTY_NONE;
+
+ // Look for type before continuing.
+
+ CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
+
+ intPrevValue = 7;
+
+ for (std::map<int, int>::iterator intiter = SplitPoints.begin();
+ intiter != SplitPoints.end(); ++intiter){
+
+ SLiter = SplitLength.find(intiter->first);
+
+ PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
+
+ wxStringTokenizer PropertyElement (PropertyData, wxT("="));
+ PropertyName = PropertyElement.GetNextToken();
+ PropertyValue = PropertyElement.GetNextToken();
+
+ intPrevValue = intiter->second;
+
+ // Process properties.
+
+ size_t intPropertyValueLen = PropertyValue.Len();
+
+ if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
+
+ PropertyValue.Trim();
+ PropertyValue.RemoveLast();
+
+ }
+
+ if (PropertyValue.Mid(0, 1) == wxT("\"")){
+
+ PropertyValue.Remove(0, 1);
+
+ }
+
+ CaptureString(&PropertyValue, FALSE);
+
+ if (PropertyName == wxT("ALTID")){
+
+ SourceListAltID.erase(*SourceCount);
+ SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
+
+ } else if (PropertyName == wxT("PID")){
+
+ SourceListPID.erase(*SourceCount);
+ SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
+
+ } else if (PropertyName == wxT("PREF")){
+
+ ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount);
+
+ } else if (PropertyName == wxT("MEDIATYPE")){
+
+ SourceListMediatype.erase(*SourceCount);
+ SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
+
+ } else {
+
+ // Something else we don't know about so append
+ // to the tokens variable.
+
+ if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
+
+ if (FirstToken == TRUE){
+
+ PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+ FirstToken = FALSE;
+
+ } else {
+
+ PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ intPropertyLen = PropertySeg2.Len();
+ SplitPoints.clear();
+ SplitLength.clear();
+ intSplitsFound = 0;
+ intSplitSize = 0;
+ intPrevValue = 0;
+
+ CaptureString(&PropertySeg2, FALSE);
+
+ // Add the data to the General/Home/Work address variables.
+
+ switch(PropType){
+ case PROPERTY_NONE:
+ break;
+ case PROPERTY_HOME:
+ SourceListType.insert(std::make_pair(*SourceCount, "home"));
+ break;
+ case PROPERTY_WORK:
+ SourceListType.insert(std::make_pair(*SourceCount, "work"));
+ break;
+ }
+
+ SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
+
+ if (!PropertyTokens.IsEmpty()){
+
+ SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
+
+ }
+
+}
+
+void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
+
+ std::map<int, int> SplitPoints;
+ std::map<int, int> SplitLength;
+
+ int intPrevValue = 5;
+ int intPref = 0;
+ int intType = 0;
+
+ SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
+
+ intPrevValue = 4;
+
+ wxString PropertyName;
+ wxString PropertyValue;
+ wxString PropertyData;
+ wxString PropertyTokens;
+ std::map<int,int>::iterator SLiter;
+ bool FirstToken = TRUE;
+
+ for (std::map<int, int>::iterator intiter = SplitPoints.begin();
+ intiter != SplitPoints.end(); ++intiter){
+
+ SLiter = SplitLength.find(intiter->first);
+
+ PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
+
+ wxStringTokenizer PropertyElement (PropertyData, wxT("="));
+ PropertyName = PropertyElement.GetNextToken();
+ PropertyValue = PropertyElement.GetNextToken();
+
+ intPrevValue = intiter->second;
+
+ CaptureString(&PropertyValue, FALSE);
+
+ if (PropertyName == wxT("ALTID")){
+
+ XMLListAltID.erase(*XMLCount);
+ XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
+
+ }
+
+ }
+
+ XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
+
+}
+
void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
std::map<int, int> SplitPoints;
} else if (PropertyName == wxT("PREF")){
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- GroupsListPref.erase(*GroupCount);
- GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount);
} else if (PropertyName == wxT("MEDIATYPE")){
} else if (PropertyName == wxT("PREF")){
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- FullNamesListPref.erase(*FNCount);
- FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, &FullNamesListPref, &PropertyValue, FNCount);
} else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
if (iter->first == 1){
- // Deal with family name.
-
- NameSurname = iter->second;
+ // Deal with family name.
+
+ NameSurname = iter->second;
+
+ } else if (iter->first == 2){
+
+ // Deal with given names.
+
+ NameForename = iter->second;
+
+ } else if (iter->first == 3){
+
+ // Deal with additional names.
+
+ NameOtherNames = iter->second;
+
+ } else if (iter->first == 4){
+
+ // Deal with honorifix prefixes and suffixes.
+
+ NameTitle = iter->second;
+
+ iter++;
+
+ if (iter == NameValues.end()){
+
+ break;
+
+ }
+
+ NameSuffix = iter->second;
+
+ }
+
+ }
+
+ // Add the name token data.
+
+ if (!PropertyTokens.IsEmpty()){
+
+ NameTokens = PropertyTokens;
+
+ }
+
+}
+
+void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
+
+ size_t intPropertyLen = PropertySeg1.Len();
+ std::map<int, int> SplitPoints;
+ std::map<int, int> SplitLength;
+ std::map<int, int>::iterator SLiter;
+ wxString PropertyData;
+ wxString PropertyName;
+ wxString PropertyValue;
+ wxString PropertyTokens;
+ bool FirstToken = TRUE;
+ int intSplitsFound = 0;
+ int intSplitSize = 0;
+ int intPrevValue = 14;
+ int intPref = 0;
+ int intType = 0;
+
+ SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
+
+ intPrevValue = 13;
+
+ for (std::map<int, int>::iterator intiter = SplitPoints.begin();
+ intiter != SplitPoints.end(); ++intiter){
+
+ SLiter = SplitLength.find(intiter->first);
+
+ PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
+
+ wxStringTokenizer PropertyElement (PropertyData, wxT("="));
+ PropertyName = PropertyElement.GetNextToken();
+ PropertyValue = PropertyElement.GetNextToken();
- } else if (iter->first == 2){
+ intPrevValue = intiter->second;
- // Deal with given names.
-
- NameForename = iter->second;
+ // Process properties.
- } else if (iter->first == 3){
+ size_t intPropertyValueLen = PropertyValue.Len();
- // Deal with additional names.
+ if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
- NameOtherNames = iter->second;
-
- } else if (iter->first == 4){
-
- // Deal with honorifix prefixes and suffixes.
-
- NameTitle = iter->second;
-
- iter++;
+ PropertyValue.Trim();
+ PropertyValue.RemoveLast();
- if (iter == NameValues.end()){
+ }
+
+ if (PropertyValue.Mid(0, 1) == wxT("\"")){
- break;
+ PropertyValue.Remove(0, 1);
- }
+ }
- NameSuffix = iter->second;
+ CaptureString(&PropertyValue, FALSE);
+
+ if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
+
+ continue;
}
+
+ if (FirstToken == TRUE){
+
+ PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+ FirstToken = FALSE;
+
+ } else {
+
+ PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
+
+ }
- }
+ }
- // Add the name token data.
+ CaptureString(&PropertySeg2, FALSE);
+
+ ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
if (!PropertyTokens.IsEmpty()){
- NameTokens = PropertyTokens;
+ ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
}
} else if (PropertyName == wxT("PREF")){
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- NicknamesListPref->erase(*NicknameCount);
- NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, NicknamesListPref, &PropertyValue, NicknameCount);
} else if (PropertyName == wxT("LANGUAGE")){
} else if (PropertyName == wxT("PREF")){
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- TZListPref->erase(*TimeZoneCount);
- TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, TZListPref, &PropertyValue, TimeZoneCount);
} else if (PropertyName == wxT("MEDIATYPE")){
AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
} else if (PropertyName == wxT("PREF")){
-
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- AddressListPref->erase(*AddressCount);
- AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
- }
+ ProcessIntegerValue(this, AddressListPref, &PropertyValue, AddressCount);
} else {
} else if (PropertyName == wxT("PREF")){
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- EmailListPref->erase(*EmailCount);
- EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, EmailListPref, &PropertyValue, EmailCount);
} else {
} else if (PropertyName == wxT("PREF")){
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- IMListPref->erase(*IMCount);
- IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, IMListPref, &PropertyValue, IMCount);
} else {
TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
} else if (PropertyName == wxT("PREF")){
-
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
- if (ValidNumber == TRUE){
-
- TelephoneListPref->erase(*TelephoneCount);
- TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, TelephoneListPref, &PropertyValue, TelephoneCount);
} else {
} else if (PropertyName == wxT("PREF")){
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- LanguageListPref->erase(*LanguageCount);
- LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, LanguageListPref, &PropertyValue, LanguageCount);
} else {
GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
} else if (PropertyName == wxT("PREF")){
-
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
- GeopositionListPref->erase(*GeographicCount);
- GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(this, GeopositionListPref, &PropertyValue, GeographicCount);
} else {
}
} else if (PropertyName == wxT("LANGUAGE")){
-
- GeneralRelatedListLanguage.erase(*RelatedCount);
- GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
+
+ ProcessIntegerValue(this, &GeneralRelatedListPref, &PropertyValue, RelatedCount);
} else if (PropertyName != wxT("TYPE")) {
WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
} else if (PropertyName == wxT("PREF")){
-
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- WebsiteListPref->erase(*URLCount);
- WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
- }
-
+ ProcessIntegerValue(this, WebsiteListPref, &PropertyValue, URLCount);
+
} else if (PropertyName == wxT("MEDIATYPE")){
WebsiteListMediatype->erase(*URLCount);
TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
} else if (PropertyName == wxT("PREF")){
-
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
- if (ValidNumber == TRUE){
-
- TitleListPref->erase(*TitleCount);
- TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
-
- }
-
+ ProcessIntegerValue(this, TitleListPref, &PropertyValue, TitleCount);
+
} else if (PropertyName == wxT("LANGUAGE")){
TitleListLanguage->erase(*TitleCount);
RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
} else if (PropertyName == wxT("PREF")){
-
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
-
- RoleListPref->erase(*RoleCount);
- RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
- }
-
+ ProcessIntegerValue(this, RoleListPref, &PropertyValue, RoleCount);
+
} else if (PropertyName == wxT("LANGUAGE")){
RoleListLanguage->erase(*RoleCount);
OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
} else if (PropertyName == wxT("PREF")){
-
- int PriorityNumber = 0;
- bool ValidNumber = TRUE;
-
- try{
- PriorityNumber = std::stoi(PropertyValue.ToStdString());
- }
-
- catch(std::invalid_argument &e){
- ValidNumber = FALSE;
- }
-
- if (ValidNumber == TRUE){
- OrganisationsListPref->erase(*OrganisationCount);
- OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
-
- }
-
+ ProcessIntegerValue(this, OrganisationsListPref, &PropertyValue, OrganisationCount);
+
} else if (PropertyName == wxT("LANGUAGE")){
OrganisationsListLanguage->erase(*OrganisationCount);
}
+void ProcessIntegerValue(ContactDataObject *ContactData,
+ std::map<int,int> *PrefPtr,
+ wxString *PropertyValue,
+ int *ItemCount){
+
+ int PriorityNumber = 0;
+ bool ValidNumber = TRUE;
+
+ try{
+ PriorityNumber = std::stoi(PropertyValue->ToStdString());
+ }
+
+ catch(std::invalid_argument &e){
+ ValidNumber = FALSE;
+ }
+
+ if (ValidNumber == TRUE){
+
+ PrefPtr->erase(*ItemCount);
+ PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
+
+ }
+
+}
+
void SplitValues(wxString *PropertyLine,
std::map<int,int> *SplitPoints,
std::map<int,int> *SplitLength,