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 | |
parent | cfdfbb4f414dee7b65f846d098651e6ba1e33d0a (diff) |
- added button to TabSRMM-toolbar
git-svn-id: http://mirotr.googlecode.com/svn/trunk@17 eced67a3-f377-a0ae-92ae-d6de1850b05a
-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 | ||||
-rw-r--r-- | miranda/include/m_msg_buttonsbar.h | 120 |
5 files changed, 177 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 diff --git a/miranda/include/m_msg_buttonsbar.h b/miranda/include/m_msg_buttonsbar.h new file mode 100644 index 0000000..31735f8 --- /dev/null +++ b/miranda/include/m_msg_buttonsbar.h @@ -0,0 +1,120 @@ +#ifndef M_MSG_BUTTONSBAR_H__
+#define M_MSG_BUTTONSBAR_H__
+
+//////////////////////////////////////////////////////////////////////////
+// Services
+//
+//////////////////////////////////////////////////////////////////////////
+// Adding a button
+//
+// wParam = 0
+// lParam = (BBButton *) &description
+#define MS_BB_ADDBUTTON "TabSRMM/ButtonsBar/AddButton"
+
+//////////////////////////////////////////////////////////////////////////
+// Remove button
+//
+// wParam = 0
+// lParam = (BBButton *) &description, only button ID and ModuleName used
+#define MS_BB_REMOVEBUTTON "TabSRMM/ButtonsBar/RemoveButton"
+
+//////////////////////////////////////////////////////////////////////////
+// ModifyButton(global)
+//
+// wParam = 0
+// lParam = (BBButton *) &description
+#define MS_BB_MODIFYBUTTON "TabSRMM/ButtonsBar/ModifyButton"
+
+
+#define BBSF_HIDDEN (1<<0)
+#define BBSF_DISABLED (1<<1)
+#define BBSF_PUSHED (1<<2)
+#define BBSF_RELEASED (1<<3)
+
+//////////////////////////////////////////////////////////////////////////
+// GetButtonState(local)
+//
+// wParam = hContact
+// lParam = (BBButton *) &description , only ModuleName and ID used
+// Returns BBButton struct with BBSF_ bbbFlags:
+#define MS_BB_GETBUTTONSTATE "TabSRMM/ButtonsBar/GetButtonState"
+
+//////////////////////////////////////////////////////////////////////////
+// SetButtonState (local)
+//
+// wParam = hContact
+// lParam = (BBButton *) &description , ModuleName, ID,hIcon,Tooltip, and BBSF_ bbbFlags are used
+#define MS_BB_SETBUTTONSTATE "TabSRMM/ButtonsBar/SetButtonState"
+
+
+////////////////////////////////////////////////////////////////
+//Events
+//
+///////////////////////////////////////////////////
+// ToolBar loaded event
+// wParam = 0;
+// lParam = 0;
+// This event will be send after module loaded and after each toolbar reset
+// You should add your buttons on this event
+#define ME_MSG_TOOLBARLOADED "TabSRMM/ButtonsBar/ModuleLoaded"
+
+///////////////////////////////////////////////////
+// ButtonClicked event
+// wParam = (HANDLE)hContact;
+// lParam = (CustomButtonClickData *)&CustomButtonClickData;
+// catch to show a popup menu, etc.
+#define ME_MSG_BUTTONPRESSED "TabSRMM/ButtonsBar/ButtonPressed"
+
+
+//event flags
+#define BBCF_RIGHTBUTTON (1<<0)
+#define BBCF_SHIFTPRESSED (1<<1)
+#define BBCF_CONTROLPRESSED (1<<2)
+#define BBCF_ARROWCLICKED (1<<3)
+
+typedef struct {
+ int cbSize;
+ POINT pt; // screen coordinates for menus
+ char* pszModule; // button owners name
+ DWORD dwButtonId; // registered button ID
+ HWND hwndFrom; // button parents HWND
+ HANDLE hContact; //
+ DWORD flags; // BBCF_ flags
+ } CustomButtonClickData;
+
+
+//button flags
+#define BBBF_DISABLED (1<<0)
+#define BBBF_HIDDEN (1<<1)
+#define BBBF_ISPUSHBUTTON (1<<2)
+#define BBBF_ISARROWBUTTON (1<<3)
+#define BBBF_ISCHATBUTTON (1<<4)
+#define BBBF_ISIMBUTTON (1<<5)
+#define BBBF_ISLSIDEBUTTON (1<<6)
+#define BBBF_ISRSIDEBUTTON (1<<7)
+#define BBBF_CANBEHIDDEN (1<<8)
+#define BBBF_ISDUMMYBUTTON (1<<9)
+#define BBBF_ANSITOOLTIP (1<<10)
+
+#define BBBF_CREATEBYID (1<<11) //only for tabsrmm internal use
+
+typedef struct _tagBBButton
+ {
+ int cbSize; // size of structure
+
+ DWORD dwButtonID; // your button ID, will be combined with pszModuleName for storing settings, etc...
+
+ char* pszModuleName; //module name without spaces and underline symbols (e.g. "tabsrmm")
+ union{
+ char* pszTooltip; //button's tooltip
+ TCHAR* ptszTooltip;
+ };
+ DWORD dwDefPos; // default order pos of button, counted from window edge (left or right)
+ // use value >100, because internal buttons using 10,20,30... 80, etc
+ int iButtonWidth; // must be 0
+ DWORD bbbFlags; // combine of BBBF_ flags above
+ HANDLE hIcon; //Handle to icolib registered icon, it's better to register with pszSection = "TabSRMM/Toolbar"
+ }BBButton;
+
+
+#endif //M_MSG_BUTTONSBAR_H__
|