summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp97
-rw-r--r--messages.cpp35
-rw-r--r--new_gpg.rc3
-rw-r--r--resource.h5
4 files changed, 131 insertions, 9 deletions
diff --git a/main.cpp b/main.cpp
index 7adec85..eeefe97 100644
--- a/main.cpp
+++ b/main.cpp
@@ -26,7 +26,7 @@ void test()
TCHAR cmd[512];
_tcscpy(cmd, _T("--list-secret-keys"));
pxExecute(cmd, "", &out, &code);
- MessageBoxA(0, out.c_str(), "test", MB_OK);
+// MessageBoxA(0, out.c_str(), "test", MB_OK);
}
@@ -34,11 +34,106 @@ HWND hwndFirstRun = NULL;
static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
+ HWND hwndList=GetDlgItem(hwndDlg, IDC_KEY_LIST);
+ LVCOLUMN col = {0};
+ LVITEM item = {0};
+ NMLISTVIEW * hdr = (NMLISTVIEW *) lParam;
switch (msg)
{
case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
+ col.pszText = _T("Fingerprint");
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = 50;
+ ListView_InsertColumn(hwndList, 0, &col);
+ ZeroMemory(&col,sizeof(col));
+ col.pszText = _T("Email");
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = 30;
+ ListView_InsertColumn(hwndList, 1, &col);
+ ZeroMemory(&col,sizeof(col));
+ col.pszText = _T("Name");
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = 250;
+ ListView_InsertColumn(hwndList, 2, &col);
+ ZeroMemory(&col,sizeof(col));
+ col.pszText = _T("Creation date");
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = 30;
+ ListView_InsertColumn(hwndList, 3, &col);
+ ZeroMemory(&col,sizeof(col));
+ col.pszText = _T("Key length");
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = 30;
+ ListView_InsertColumn(hwndList, 4, &col);
+ ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_FULLROWSELECT);
+ int i = 1, iRow = 0;
+ { //parse gpg output
+ item.mask = LVIF_TEXT;
+ item.iItem = i;
+ item.iSubItem = 0;
+ item.pszText = _T("");
+ {
+ string out;
+ DWORD code;
+// iRow = ListView_InsertItem(hwndList, &item);
+ string::size_type p = 0, p2 = 0, stop = 0;
+ {
+ TCHAR cmd[512];
+ _tcscpy(cmd, _T("--list-secret-keys"));
+ pxExecute(cmd, "", &out, &code);
+ }
+ while(p != string::npos)
+ {
+ if((p = out.find("sec ", p) + 5) == string::npos)
+ break;
+ if(p < stop)
+ break;
+ stop = p;
+ p2 = out.find("/", p) - 1;
+ TCHAR *tmp = mir_a2t(out.substr(p,p2-p).c_str());
+ item.pszText = tmp;
+ iRow = ListView_InsertItem(hwndList, &item);
+ ListView_SetItemText(hwndList, iRow, 4, tmp);
+ mir_free(tmp);
+ p2+=2;
+ p = out.find(" ", p2);
+ tmp = mir_a2t(out.substr(p2,p-p2).c_str());
+ ListView_SetItemText(hwndList, iRow, 0, tmp);
+ mir_free(tmp);
+ p = out.find("uid ", p);
+ p2 = out.find_first_not_of(" ", p+5);
+ p = out.find(" ", p2);
+ tmp = mir_a2t(out.substr(p2,p-p2).c_str());
+ ListView_SetItemText(hwndList, iRow, 2, tmp);
+ mir_free(tmp);
+ p = out.find("<", p) + 1;
+ p2 = out.find(">", p);
+ tmp = mir_a2t(out.substr(p,p2-p).c_str());
+ ListView_SetItemText(hwndList, iRow, 1, tmp);
+ mir_free(tmp);
+ p = out.find("ssb ", p2) + 6;
+ p = out.find(" ", p) + 1;
+ p2 = out.find("\n", p);
+ tmp = mir_a2t(out.substr(p,p2-p-1).c_str());
+ ListView_SetItemText(hwndList, iRow, 3, tmp);
+ mir_free(tmp);
+ i++;
+ }
+ }
+ ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);// not sure about this
+ ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 2, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 4, LVSCW_AUTOSIZE);
+ }
+
return TRUE;
}
diff --git a/messages.cpp b/messages.cpp
index 38205cb..c4a890d 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -29,15 +29,25 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
return CallService(MS_PROTO_CHAINRECV, w, l);
bool unicode = (bool)(pre->flags&PREF_UNICODE);
- { //check for public key
- string str = msg;
- string::size_type s1, s2;
- if(((s2 = str.find("-----END PGP PUBLIC KEY BLOCK-----")) != string::npos) && ((s1 = str.find("-----BEGIN PGP PUBLIC KEY BLOCK-----")) != string::npos))
+ { //check for gpg related data
+ wchar_t *tmp = mir_utf8decodeW(msg);
+ wstring str = tmp;
+ mir_free(tmp);
+ wstring::size_type s1, s2;
+
+ if(((s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----"))) != wstring::npos) && ((s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----"))) != wstring::npos))
{ //this is public key
}
- else if(((s2 = str.find("-/ENCRYPTED-")) != string::npos) && ((s1 = str.find("-ENCRYPTED-")) != string::npos))
- { //this is encrypted data block
+ else if(((s2 = str.find(_T("-/ENCRYPTED-"))) != wstring::npos) && ((s1 = str.find(_T("-ENCRYPTED-"))) != wstring::npos))
+ { //this is generic encrypted data block
+ }
+ else if(((s1 = str.find(_T("<body>This message is encrypted.</body>"))) != wstring::npos))
+ { //this is jabber encrypted data
}
+
+ char *utf = mir_utf8encodeW(str.c_str()); //for later usage
+ mir_free(utf);
+
}
return CallService(MS_PROTO_CHAINRECV, w, l);
@@ -48,10 +58,23 @@ int SendMsgSvc(WPARAM w, LPARAM l)
CCSDATA *ccs = (CCSDATA*)l;
if (!ccs)
return CallService(MS_PROTO_CHAINSEND, w, l);
+ if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0))
+ return CallService(MS_PROTO_CHAINSEND, w, l);
+
char *msg = (char*)(ccs->lParam);
if (!msg)
return CallService(MS_PROTO_CHAINSEND, w, l);
bool unicode = (bool)(ccs->wParam&PREF_UNICODE);
+ { //encrypt data here
+ wchar_t *tmp = mir_utf8decodeW(msg);
+ wstring str = tmp;
+ mir_free(tmp);
+ wstring::size_type s1, s2;
+
+ char *utf = mir_utf8encodeW(str.c_str()); //for later usage
+ mir_free(utf);
+ }
+
return CallService(MS_PROTO_CHAINSEND, w, l);
} \ No newline at end of file
diff --git a/new_gpg.rc b/new_gpg.rc
index 6b5dce6..d970eb8 100644
--- a/new_gpg.rc
+++ b/new_gpg.rc
@@ -68,6 +68,9 @@ CAPTION "new GPG Plugin First Run"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "خت",ID_OK,15,175,50,14
+ CONTROL "",IDC_KEY_LIST,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,14,22,189,50
+ PUSHBUTTON "Generate key",IDC_GENERATE_KEY,15,76,54,14
+ LTEXT "Select key for use",IDC_STATIC,16,12,186,8
END
diff --git a/resource.h b/resource.h
index c5d1d12..e52578e 100644
--- a/resource.h
+++ b/resource.h
@@ -3,7 +3,6 @@
// Used by new_gpg.rc
//
#define IDD_LOAD_PUBLIC_KEY 102
-#define IDD_DIALOG1 103
#define IDD_FIRST_RUN 103
#define IDD_OPT_GPG 104
#define IDD_OPT_GPG_BIN 105
@@ -20,7 +19,9 @@
#define IDC_PUBLIC_KEY_EDIT 1025
#define IDC_BUTTON1 1026
#define IDC_SAVE_KEY_BUTTON 1026
+#define IDC_GENERATE_KEY 1026
#define IDC_DELETE_KEY_BUTTON 1027
+#define IDC_KEY_LIST 1028
// Next default values for new objects
//
@@ -28,7 +29,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1028
+#define _APS_NEXT_CONTROL_VALUE 1029
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif