/** * name: SvcExImport_Export * desc: service function to export contact information * param: wParam - handle to contact or NULL * lParam - parent window * return: 0 always **/ INT_PTR SvcExImport_Export(lpExImParam ExImContact, HWND hwndParent) { CHAR szFileName[MAX_PATH] = { 0 }; // create the filename to suggest the user for the to export contact DisplayNameToFileName(ExImContact, szFileName, _countof(szFileName)); int nIndex = DlgExIm_SaveFileName(hwndParent, Translate("Select a destination file..."), FilterString(ExImContact), szFileName); switch (nIndex) { case 1: // .xml { CFileXml xmlFile; return xmlFile.Export(ExImContact, szFileName); } case 2: // .ini { return SvcExImINI_Export(ExImContact, szFileName); } case 3: // .vcf { CVCardFileVCF vcfFile; SetCursor(LoadCursor(NULL, IDC_WAIT)); if (vcfFile.Open(ExImContact->hContact, szFileName, "wt")) { vcfFile.Export(FALSE); vcfFile.Close(); } SetCursor(LoadCursor(NULL, IDC_ARROW)); return 0; } } return 1; }
/** * name: SvcExImport_Import * desc: service function to export contact information * param: wParam - handle to contact or NULL * lParam - parent window * return: 0 always **/ INT_PTR SvcExImport_Import(lpExImParam ExImContact, HWND hwndParent) { CHAR szFileName[MAX_PATH] = { 0 }; // create the filename to suggest the user for the to export contact DisplayNameToFileName(ExImContact, szFileName, _countof(szFileName)); int nIndex = DlgExIm_OpenFileName(hwndParent, Translate("Import User Details from VCard"), FilterString(ExImContact), szFileName); // Stop during develop if (ExImContact->Typ == EXIM_ACCOUNT || ExImContact->Typ == EXIM_GROUP) return 1; switch (nIndex) { case 1: { CFileXml xmlFile; CallService(MS_CLIST_SETHIDEOFFLINE, -1, 0); //workarround to refresh the clist.... xmlFile.Import(ExImContact->hContact, szFileName); CallService(MS_CLIST_SETHIDEOFFLINE, -1, 0); //...after import. //pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); //does not work return 0; } // .ini case 2: return SvcExImINI_Import(ExImContact->hContact, szFileName); // .vcf case 3: { CVCardFileVCF vcfFile; if (vcfFile.Open(ExImContact->hContact, szFileName, "rt")) { SetCursor(LoadCursor(NULL, IDC_WAIT)); vcfFile.Import(); vcfFile.Close(); SetCursor(LoadCursor(NULL, IDC_ARROW)); } return 0; } } return 1; }
Bool ProcessFile(LPVoid lpBuffer, LPVoid lpEndOfBuffer, PWChar pszFileName) { FILE *fp; Int32 RecvSize, LineNum; WChar ch, line1[0x500], line2[0x500], path[MAX_PATH]; PWChar pBuffer, pEnd, p1, p2, p; pBuffer = (PWChar)lpBuffer; pEnd = (PWChar)lpEndOfBuffer; if (pBuffer >= pEnd) return False; wcscpy(path, pszFileName); wcscat(path, L".txt"); fp = _wfopen(path, L"wb"); if (!fp) fp = stdout; else { UInt16 bom = 0xFEFF; fwrite(&bom, 2, 1, fp); } LineNum = 0; while (pBuffer < pEnd) { RecvSize = sizeof(line1); if (++LineNum, PeekLine(pBuffer, pEnd, line1, &RecvSize) == False) break; if (RecvSize == 0) break; RecvSize /= 2; pBuffer += RecvSize; while (RecvSize > 0 && (ch = line1[--RecvSize])) { if (ch != '\r' && ch != '\n') break; line1[RecvSize] = 0; } p1 = line1; while (*p1 == ' ' || *p1 == '\t' || *p1 == L'¡¡') ++p1; if (IsCommandSentance(*p1)) { if (fp != stdout) { FilterString(line1, -1); fwprintf(fp, L"%s\n", line1); } continue; } if (!wcsncmp(line1, L"op01YOU064", 10)) __asm nop; RecvSize = sizeof(line2); if (++LineNum, PeekLine(pBuffer, pEnd, line2, &RecvSize) == False) break; if (RecvSize == 0) break; RecvSize /= 2; pBuffer += RecvSize; while (RecvSize > 0 && (ch = line2[--RecvSize])) { if (ch != '\r' && ch != '\n') break; line2[RecvSize] = 0; } p2 = line2; while (*p2 == ' ' || *p2 == '\t' || *p2 == L'¡¡') ++p2; if (IsCommandSentance(*p2)) { PWChar pline = line2; // if (line2[0] == 0) { FilterString(line1, -1); fwprintf(fp, L"%s\n", line1); wprintf(L"%s\nformat corrupt at %u line\n\n", pszFileName, LineNum); getch(); } if (fp != stdout) { FilterString(line2, -1); fwprintf(fp, L"%s\n", line2); } continue; } p1 = line1; p2 = line2; p = wcschr(p1, ','); if (p) p1 = p + 1; while (*p1 == ' ' || *p1 == '\t' || *p1 == L'¡¡') ++p1; while (*p2 == ' ' || *p2 == '\t' || *p2 == L'¡¡') ++p2; ReplaceMark(p2, p1); if (fp == stdout) fwprintf(fp, L"%s\n%s\n\n", p1, p2); else { *p1 = 0; fwprintf(fp, L"%s%s\n\n", line1, p2); } } fclose(fp); return True; }