diff options
author | admin@progandy.co.cc <admin@progandy.co.cc@eced67a3-f377-a0ae-92ae-d6de1850b05a> | 2010-09-16 16:00:22 +0000 |
---|---|---|
committer | admin@progandy.co.cc <admin@progandy.co.cc@eced67a3-f377-a0ae-92ae-d6de1850b05a> | 2010-09-16 16:00:22 +0000 |
commit | 06489e7bae767e5b0d0d6be35f4ceb1c28cfc59d (patch) | |
tree | 18f7bb05dee1c7b52c157606249640d580aa8380 /MirOTR | |
parent | cfdfbb4f414dee7b65f846d098651e6ba1e33d0a (diff) |
- added button to TabSRMM-toolbar
git-svn-id: http://mirotr.googlecode.com/svn/trunk@17 eced67a3-f377-a0ae-92ae-d6de1850b05a
Diffstat (limited to 'MirOTR')
-rw-r--r-- | MirOTR/options.cpp | 1 | ||||
-rw-r--r-- | MirOTR/options.h | 2 | ||||
-rw-r--r-- | MirOTR/stdafx.h | 1 | ||||
-rw-r--r-- | MirOTR/svcs_srmm.cpp | 59 |
4 files changed, 57 insertions, 6 deletions
diff --git a/MirOTR/options.cpp b/MirOTR/options.cpp index 3cc2d07..eb24ec0 100644 --- a/MirOTR/options.cpp +++ b/MirOTR/options.cpp @@ -103,6 +103,7 @@ void LoadOptions() { options.bHavePopups = 0!=ServiceExists(MS_POPUP_ADDPOPUPT) && ServiceExists(MS_POPUP_SHOWMESSAGE);
options.bHaveSRMMIcons = 0!=ServiceExists(MS_MSG_MODIFYICON);
options.bHaveSecureIM = 0!=ServiceExists("SecureIM/IsContactSecured");
+ options.bHaveButtonsBar = 0!=ServiceExists(MS_BB_ADDBUTTON);
LoadFilenames();
}
diff --git a/MirOTR/options.h b/MirOTR/options.h index 7a2ecec..64ca730 100644 --- a/MirOTR/options.h +++ b/MirOTR/options.h @@ -33,7 +33,7 @@ typedef struct { bool end_offline, end_window_close;
// temporary options
- bool bHaveMetaContacts, bHavePopups, bHaveSRMMIcons, bHaveSecureIM;
+ bool bHaveMetaContacts, bHavePopups, bHaveSRMMIcons, bHaveSecureIM, bHaveButtonsBar;
} Options;
diff --git a/MirOTR/stdafx.h b/MirOTR/stdafx.h index dbf05ce..035af51 100644 --- a/MirOTR/stdafx.h +++ b/MirOTR/stdafx.h @@ -41,6 +41,7 @@ #include <m_contacts.h> #include <m_utils.h>
#include <m_icolib.h>
+#include <m_msg_buttonsbar.h>
#include <gcrypt.h>
extern "C" {
diff --git a/MirOTR/svcs_srmm.cpp b/MirOTR/svcs_srmm.cpp index 98bc770..6eff845 100644 --- a/MirOTR/svcs_srmm.cpp +++ b/MirOTR/svcs_srmm.cpp @@ -2,6 +2,7 @@ #include "mirotrmenu.h"
HANDLE hEventIconPressed;
HICON hIconNotSecure, hIconFinished, hIconPrivate, hIconUnverified;
+BBButton OTRButton;
int WindowEvent(WPARAM wParam, LPARAM lParam) {
MessageWindowEventData *mwd = (MessageWindowEventData *)lParam;
@@ -147,8 +148,9 @@ void SetEncryptionStatus(HANDLE hContact, TrustLevel level) { // if(!chat_room) DBWriteContactSettingByte(hContact, MODULENAME, "Encrypted", (encrypted ? 1 : 0));
- if(options.bHaveSRMMIcons) {
+ if(options.bHaveSRMMIcons || options.bHaveButtonsBar) {
//strcat(dbg_msg, "\nchanging icon");
+ BBButton button = OTRButton;
StatusIconData sid = {0}, sid2={0};
sid.cbSize = sizeof(sid);
sid.szModule = MODULENAME;
@@ -163,20 +165,33 @@ void SetEncryptionStatus(HANDLE hContact, TrustLevel level) { switch (level) {
case TRUST_FINISHED:
sid.flags = 0;
+ button.ptszTooltip = TranslateT(LANG_STATUS_FINISHED);
+ button.hIcon = GetIconHandle(ICON_FINISHED);
break;
case TRUST_UNVERIFIED:
sid2.flags = MBF_DISABLED;
+ button.ptszTooltip = TranslateT(LANG_STATUS_UNVERIFIED);
+ button.hIcon = GetIconHandle(ICON_UNVERIFIED);
break;
case TRUST_PRIVATE:
sid2.flags = 0;
+ button.ptszTooltip = TranslateT(LANG_STATUS_PRIVATE);
+ button.hIcon = GetIconHandle(ICON_PRIVATE);
break;
default:
sid.flags = MBF_DISABLED;
+ button.ptszTooltip = TranslateT(LANG_STATUS_DISABLED);
+ button.hIcon = GetIconHandle(ICON_NOT_PRIVATE);
break;
}
+ } else {
+ button.bbbFlags |= BBBF_HIDDEN;
+ }
+ if (options.bHaveSRMMIcons) {
+ CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
+ CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid2);
}
- CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
- CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid2);
+ if (options.bHaveButtonsBar) CallService(MS_BB_SETBUTTONSTATE, (WPARAM)hContact, (LPARAM)&button);
db_dword_set(hContact, MODULENAME, "TrustLevel", level);
if(!chat_room && options.bHaveMetaContacts) {
@@ -190,8 +205,27 @@ void SetEncryptionStatus(HANDLE hContact, TrustLevel level) { //PUShowMessage(dbg_msg, SM_NOTIFY);
}
+int SVC_ButtonsBarLoaded(WPARAM, LPARAM) {
+ CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&OTRButton);
+ return 0;
+}
+int SVC_ButtonsBarPressed(WPARAM w, LPARAM l) {
+ CustomButtonClickData* cbcd = (CustomButtonClickData *)l;
+ if (cbcd->cbSize == (int)sizeof(CustomButtonClickData) && cbcd->dwButtonId == 0 && strcmp(cbcd->pszModule, MODULENAME)==0) {
+ HANDLE hContact = (HANDLE)w;
+
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if(proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0))
+ return 0;
+ ShowOTRMenu(hContact, cbcd->pt);
+
+ }
+ return 0;
+}
+
void InitSRMM() {
// add icon to srmm status icons
+ InitMirOTRMenu();
if(options.bHaveSRMMIcons) {
hIconNotSecure = LoadIcon(ICON_NOT_PRIVATE, 0);
hIconFinished = LoadIcon(ICON_FINISHED, 0);
@@ -216,7 +250,22 @@ void InitSRMM() { // hook the window events so that we can can change the status of the icon
hEventIconPressed = HookEvent(ME_MSG_ICONPRESSED, SVC_IconPressed);
- InitMirOTRMenu();
+ }
+ if (options.bHaveButtonsBar) {
+ ZeroMemory(&OTRButton, sizeof(OTRButton));
+ OTRButton.cbSize = sizeof(OTRButton);
+ OTRButton.dwButtonID = 0;
+ OTRButton.pszModuleName = MODULENAME;
+ OTRButton.dwDefPos = 200;
+#ifdef _UNICODE
+ OTRButton.bbbFlags = BBBF_ISRSIDEBUTTON|BBBF_CANBEHIDDEN|BBBF_ISIMBUTTON|BBBF_ISPUSHBUTTON;
+#else
+ OTRButton.bbbFlags = BBBF_ISRSIDEBUTTON|BBBF_CANBEHIDDEN|BBBF_ISIMBUTTON|BBBF_ISPUSHBUTTON|BBBF_ANSITOOLTIP;
+#endif
+ OTRButton.ptszTooltip = TranslateT(LANG_OTR_TOOLTIP);
+ OTRButton.hIcon = GetIconHandle(ICON_NOT_PRIVATE);
+ HookEvent(ME_MSG_TOOLBARLOADED, SVC_ButtonsBarLoaded);
+ HookEvent(ME_MSG_BUTTONPRESSED, SVC_ButtonsBarPressed);
}
}
void DeinitSRMM() {
@@ -227,6 +276,6 @@ void DeinitSRMM() { ReleaseIcon(ICON_PRIVATE, 0);
ReleaseIcon(ICON_UNVERIFIED, 0);
hIconNotSecure = hIconFinished = hIconPrivate = hIconUnverified =0;
- UninitMirOTRMenu();
}
+ UninitMirOTRMenu();
}
\ No newline at end of file |