Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added REV to the SaveString function of ContactDataObject
[xestiaab/.git] / source / contacteditor / cdo / ContactDataObject-Save.cpp
index bf755f1..9e14252 100644 (file)
@@ -79,7 +79,54 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                
        }
        
-       // TODO: Sortout REV.
+       // Process REV.
+       
+       wxDateTime DateTimeSave;
+       DateTimeSave = DateTimeSave.SetToCurrent();
+       wxString DateTimeSaveValue;
+       
+#ifdef XAB_UNITTEST
+       
+       DateTimeSaveValue += "20160703T091000Z";
+       
+#else
+    
+       DateTimeSaveValue += wxString::Format("%04i", DateTimeSave.GetYear());
+       DateTimeSaveValue += wxString::Format("%02i", (DateTimeSave.GetMonth() + 1));
+       DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetDay());
+       DateTimeSaveValue += "T";
+       DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetHour());
+       DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetMinute());
+       DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetSecond());
+       DateTimeSaveValue += "Z";
+    
+#endif
+       
+       if (!RevisionTokens.IsEmpty()){
+               
+               ProcessData.Append("REV;");
+               ProcessData.Append(RevisionTokens);
+               ProcessData.Append(":");
+               ProcessData.Append(DateTimeSaveValue);
+               ProcessData.Append("\n");
+               
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();            
+               
+       } else {
+       
+               ProcessData.Append("REV:");
+               ProcessData.Append(DateTimeSaveValue);
+               ProcessData.Append("\n");
+               
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+               
+       }
        
        // Process XML.
 
@@ -113,6 +160,17 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &SourceListMediatype, &SourceListPref, 
                &SourceListTokens, SaveData);
        
+       // Process MEMBER (if contact kind is CONTACTKIND_GROUP).
+       
+       if (ContactKind == CONTACTKIND_GROUP){
+               
+               SaveMember(&GroupsList, &GroupsListAltID, 
+                       &GroupsListPID, &GroupsListType,
+                       &GroupsListMediaType, &GroupsListPref, 
+                       &GroupsListTokens, SaveData);
+               
+       }
+       
        // Process CLIENTPIDMAP.
        
        for (std::map<int, wxString>::iterator CPIDIter = ClientPIDList.begin();
@@ -299,8 +357,12 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
 
        // TODO: Process IMPP.
        
+       
+       
        // TODO: Process TEL.
        
+       
+       
        // Process LANG.
        
        SaveLanguage(&GeneralLanguageList, &GeneralLanguageListAltID, 
@@ -606,6 +668,31 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &CalendarRequestListType, &CalendarRequestListPref,
                &CalendarRequestListTokens, SaveData);
 
+       // Process FBURL.
+       
+       SaveFreeBusyURI(&FreeBusyList, &FreeBusyListAltID, 
+               &FreeBusyListPID, &FreeBusyListType,
+               &FreeBusyListMediatype, &FreeBusyListPref, 
+               &FreeBusyListTokens, SaveData);
+
+       // Process KEY.
+       
+       SaveKey(&KeyList, &KeyListAltID, 
+               &KeyListPID, &KeyListType,
+               &KeyListKeyType, &KeyListDataEncType, 
+               &KeyListDataType, &KeyListPref, 
+               &KeyListTokens, SaveData);
+
+       // Process VND-*
+       
+       SaveVendor(&VendorList, &VendorListPEN, 
+               &VendorListElement, SaveData);
+
+       // Process X-Tokens.
+       
+       SaveXToken(&XTokenList, &XTokenListTokens, 
+               SaveData);
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -774,6 +861,85 @@ void ContactDataObject::SaveSource(map<int, wxString> *SourceList, map<int, wxSt
                
 }
 
+void ContactDataObject::SaveMember(std::map<int, wxString> *GroupsList, std::map<int, wxString> *GroupsListAltID, 
+       std::map<int, wxString> *GroupsListPID, std::map<int, wxString> *GroupsListType,
+       std::map<int, wxString> *GroupsListMediaType, std::map<int, int> *GroupsListPref, 
+       std::map<int, wxString> *GroupsListTokens, wxString *SaveData){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator GroupsIter = GroupsList->begin();
+               GroupsIter != GroupsList->end(); GroupsIter++){
+
+               ProcessData.Append("MEMBER");
+                       
+               // Check if there is a value for TYPE.
+               
+               if ((*GroupsListType)[GroupsIter->first].size() > 0){
+               
+                       ProcessData.Append(";TYPE=");
+                       ProcessData.Append((*GroupsListType)[GroupsIter->first]);
+                       
+               }
+               
+               // Check if there is a value for ALTID.
+               
+               if ((*GroupsListAltID)[GroupsIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*GroupsListAltID)[GroupsIter->first]);
+                       
+               }
+
+               // Check if there is a value for MEDIATYPE.
+               
+               if ((*GroupsListMediaType)[GroupsIter->first].size() > 0){
+               
+                       ProcessData.Append(";MEDIATYPE=");
+                       ProcessData.Append((*GroupsListMediaType)[GroupsIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*GroupsListPID)[GroupsIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*GroupsListPID)[GroupsIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*GroupsListPref)[GroupsIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*GroupsListPref)[GroupsIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*GroupsListTokens)[GroupsIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*GroupsListTokens)[GroupsIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(GroupsIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
+}
+
 void ContactDataObject::SaveNickname(map<int, wxString> *NicknameList, map<int, wxString> *NicknameListAltID, 
        map<int, wxString> *NicknameListPID, map<int, wxString> *NicknameListType,
        map<int, wxString> *NicknameListLanguage, map<int, int> *NicknameListPref, 
@@ -2114,4 +2280,206 @@ void ContactDataObject::SaveCalendarRequestURI(map<int, wxString> *CalendarReque
                        
        }
                
+}
+
+void ContactDataObject::SaveFreeBusyURI(std::map<int, wxString> *FreeBusyList, std::map<int, wxString> *FreeBusyListAltID, 
+       std::map<int, wxString> *FreeBusyListPID, std::map<int, wxString> *FreeBusyListType,
+       std::map<int, wxString> *FreeBusyListMediatype, std::map<int, int> *FreeBusyListPref, 
+       std::map<int, wxString> *FreeBusyListTokens, wxString *SaveData){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator FreeBusyIter = FreeBusyList->begin();
+               FreeBusyIter != FreeBusyList->end(); FreeBusyIter++){
+
+               ProcessData.Append("FBURL");
+                       
+               // Check if there is a value for TYPE.
+               
+               if ((*FreeBusyListType)[FreeBusyIter->first].size() > 0){
+               
+                       ProcessData.Append(";TYPE=");
+                       ProcessData.Append((*FreeBusyListType)[FreeBusyIter->first]);
+                       
+               }
+               
+               // Check if there is a value for ALTID.
+               
+               if ((*FreeBusyListAltID)[FreeBusyIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*FreeBusyListAltID)[FreeBusyIter->first]);
+                       
+               }
+
+               // Check if there is a value for MEDIATYPE.
+               
+               if ((*FreeBusyListMediatype)[FreeBusyIter->first].size() > 0){
+               
+                       ProcessData.Append(";MEDIATYPE=");
+                       ProcessData.Append((*FreeBusyListMediatype)[FreeBusyIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*FreeBusyListPID)[FreeBusyIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*FreeBusyListPID)[FreeBusyIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*FreeBusyListPref)[FreeBusyIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*FreeBusyListPref)[FreeBusyIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*FreeBusyListTokens)[FreeBusyIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*FreeBusyListTokens)[FreeBusyIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(FreeBusyIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
+}
+
+void ContactDataObject::SaveKey(map<int, wxString> *KeyList, map<int, wxString> *KeyListAltID, 
+       map<int, wxString> *KeyListPID, map<int, wxString> *KeyListType,
+       map<int, bool> *KeyListKeyType, map<int, wxString> *KeyListDataEncType, 
+       map<int, wxString> *KeyListDataType, map<int, int> *KeyListPref, 
+       map<int, wxString> *KeyListTokens, wxString *SaveData){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator KeyIter = KeyList->begin();
+               KeyIter != KeyList->end(); KeyIter++){
+
+               ProcessData.Append("KEY");
+                       
+               // Check if there is a value for TYPE.
+               
+               if ((*KeyListType)[KeyIter->first].size() > 0){
+               
+                       ProcessData.Append(";TYPE=");
+                       ProcessData.Append((*KeyListType)[KeyIter->first]);
+                       
+               }
+               
+               // Check if there is a value for ALTID.
+               
+               if ((*KeyListAltID)[KeyIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*KeyListAltID)[KeyIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*KeyListPID)[KeyIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*KeyListPID)[KeyIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*KeyListPref)[KeyIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*KeyListPref)[KeyIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*KeyListTokens)[KeyIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*KeyListTokens)[KeyIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":data:");
+               ProcessData.Append((*KeyListDataType)[KeyIter->first]);
+               ProcessData.Append(";");
+               ProcessData.Append((*KeyListDataEncType)[KeyIter->first]);
+               ProcessData.Append(",");
+               ProcessData.Append(KeyIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
+}
+
+void ContactDataObject::SaveVendor(map<int, wxString> *VendorList, map<int, wxString> *VendorListPEN, 
+       map<int, wxString> *VendorListElement, wxString *SaveData){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator VendorIter = VendorList->begin();
+               VendorIter != VendorList->end(); VendorIter++){
+
+               ProcessData.Append("VND-");
+               ProcessData.Append((*VendorListPEN)[VendorIter->first]);
+               ProcessData.Append("-");
+               ProcessData.Append((*VendorListElement)[VendorIter->first]);
+               ProcessData.Append(":");
+               ProcessData.Append(VendorIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
+}
+
+void ContactDataObject::SaveXToken(map<int, wxString> *XTokenList, map<int, wxString> *XTokenListTokens, 
+       wxString *SaveData){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator XTokenIter = XTokenList->begin();
+               XTokenIter != XTokenList->end(); XTokenIter++){
+
+               ProcessData.Append("X-");
+               ProcessData.Append((*XTokenListTokens)[XTokenIter->first]);
+               ProcessData.Append(":");
+               ProcessData.Append(XTokenIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }       
+               
 }
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy