Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / export / export-vcard3.cpp
1 #include <wx/ffile.h>
2 #include <wx/arrstr.h>
3 #include <wx/filefn.h>
4 #include <wx/tokenzr.h>
6 #include "../vcard/vcard.h"
7 #include "../vcard/vcard34conv.h"
9 void ExportVCard3(bool DirMode, wxString OutputLocation, wxArrayString *FileList, int *ExportCount){
11         if (DirMode == TRUE){
12         
13                 // Output each contact into the directory.
14         
15                 // Load the contact file and covert it to vCard 3.0.
16                 
17                 wxString Filename;
18                 wxString FinalFilename;
19                 wxString ContactData;
20                 
21                 for (int i = 0; i < FileList->GetCount(); i++){
22                 
23                         // Get the final part of the path (filename).
24                         
25                         vCard34Conv vCardConvObj;               
26                         vCardConvObj.ConvertToV3(FileList->Item(i), &ContactData);
28 #if defined(__HAIKU__)
29     
31 #elif defined(__WIN32__)
33                         wxStringTokenizer FileToken(FileList->Item(i), wxT("\\"));
35                         while (FileToken.HasMoreTokens()){
36                                 Filename = FileToken.GetNextToken();
37                         }
39                         FinalFilename.Append(OutputLocation);
40                         FinalFilename.Append(wxT("\\"));
41                         FinalFilename.Append(Filename);
43 #else
44                         
45                         wxStringTokenizer FileToken(FileList->Item(i), wxT("//"));
47                         while(FileToken.HasMoreTokens()){
48                                 Filename = FileToken.GetNextToken();
49                         }
50                 
51                         FinalFilename.Append(OutputLocation);
52                         FinalFilename.Append(wxT("/"));
53                         FinalFilename.Append(Filename);
55 #endif
57                         // Write the converted card to the file.
58                         
59                         wxFFile OutputFile;
60                         
61 #if wxABI_VERSION < 20900
62                         OutputFile.Open(FinalFilename, wxT("w"));
63 #else
64                         OutputFile.Open(FinalFilename, wxT("w"));
65 #endif
66                         
67                         OutputFile.Write(ContactData, wxConvAuto());
68                         
69                         OutputFile.Close();
70                         
71                         (*ExportCount)++;
72                         
73                         Filename.Clear();
74                         FinalFilename.Clear();
75                         ContactData.Clear();
76                 
77                 }
78         
79         } else {
80         
81                 // Output all contacts into one file.
82                 
83                 wxFFile OutputFile;
84                 
85                 // Open the output file.
86                 
87 #if wxABI_VERSION < 20900
88                 OutputFile.Open(OutputLocation.c_str(), wxT("w"));
89 #else
90                 OutputFile.Open(OutputLocation, wxT("w"));
91 #endif
92                 
93                 wxString InputFileData;
94                 
95                 for (int i = 0; i < FileList->GetCount(); i++){
96                 
97                         // Open up the input file.
99                         vCard34Conv vCardConvObj;               
100                         vCardConvObj.ConvertToV3(FileList->Item(i), &InputFileData);
102                         OutputFile.Write(InputFileData, wxConvAuto());
103                         
104                         InputFileData.Clear();
105                         
106                         (*ExportCount)++;
107                 
108                 }
109         
110                 OutputFile.Close();
111         
112         }
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