diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2012-05-28 13:53:01 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2012-05-28 13:53:01 +0300 |
commit | 31321966cc6b6008ba84236ba87748aa46a347ed (patch) | |
tree | 783176521e2539dfb74d3d968ac2a9d230210f4b | |
parent | 2a5e050f97db89343aacc773b6588a17dbd1a2c7 (diff) |
keys import in progress
-rwxr-xr-x | utilities.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/utilities.cpp b/utilities.cpp index 1353ae0..25d29c1 100755 --- a/utilities.cpp +++ b/utilities.cpp @@ -1468,7 +1468,7 @@ int ExportGpGKeys(WPARAM w, LPARAM l) int ImportGpGKeys(WPARAM w, LPARAM l) { - TCHAR *p = GetFilePath(_T("Choose file to export import keys from"), _T("*"), _T("Any file")); + TCHAR *p = GetFilePath(_T("Choose file to import keys from"), _T("*"), _T("Any file")); if(!p || !p[0]) { delete [] p; @@ -1485,18 +1485,34 @@ int ImportGpGKeys(WPARAM w, LPARAM l) file.getline(line, 255); if(!strstr(line, "-----BEGIN PGP PUBLIC KEY BLOCK-----")) return 1; //TODO: handle error - std::string key, login, contact; + std::string key, login, contact_id; key += line; key += '\n'; - while(file.is_open()) + while(file.is_open() && !file.eof()) { file.getline(line, 255); key += line; key += '\n'; if(strstr(line, "-----END PGP PUBLIC KEY BLOCK-----")) { //TODO: parse key + std::string::size_type p1 = 0, p2 = 0; + p1 = key.find("Comment: login "); + p1 += strlen("Comment: login "); + p2 = key.find(" contact_id "); + login = key.substr(p1, p2-p1); + p2 += strlen(" contact_id "); + p1 = key.find("\n", p2); + contact_id = key.substr(p2, p1-p2); + p1 = key.find("Comment: login "); + p2 = key.find("\n", p1); + p2++; + key.erase(p1, p2-p1); + + key.clear(); } } + if(file.is_open()) + file.close(); return 0; }
\ No newline at end of file |