summaryrefslogtreecommitdiff
path: root/plugins/QuickMessages/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-12-01 13:25:11 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-12-01 13:25:11 +0000
commit854959cbc0a1bad2c086214be4d1a829b17a61f3 (patch)
treeee3de50f4b4e57f54ae20d139f97fa469ff90d34 /plugins/QuickMessages/src
parent73ddc73d92675399e4619758d4b0881418de0a6d (diff)
icolib: icon creation quirks
git-svn-id: http://svn.miranda-ng.org/main/trunk@2588 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/QuickMessages/src')
-rw-r--r--plugins/QuickMessages/src/Utils.cpp338
-rw-r--r--plugins/QuickMessages/src/main.cpp216
-rw-r--r--plugins/QuickMessages/src/quickmessages.h20
3 files changed, 263 insertions, 311 deletions
diff --git a/plugins/QuickMessages/src/Utils.cpp b/plugins/QuickMessages/src/Utils.cpp
index 81f267ffe3..0d11c3f742 100644
--- a/plugins/QuickMessages/src/Utils.cpp
+++ b/plugins/QuickMessages/src/Utils.cpp
@@ -23,153 +23,151 @@ ListData* ButtonsList[100];
SortedList* QuickList=NULL;
-
typedef void (*ItemDestuctor)(void*);
-
int sstSortButtons(const void * vmtbi1, const void * vmtbi2)
- {
+{
ButtonData * mtbi1=(ButtonData *)*((ButtonData ** )vmtbi1);
ButtonData * mtbi2=(ButtonData *)*((ButtonData ** )vmtbi2);
if (mtbi1==NULL || mtbi2==NULL) return (mtbi1-mtbi2);
return mtbi1->dwPos-mtbi2->dwPos;
- }
+}
int sstQuickSortButtons(const void * vmtbi1, const void * vmtbi2)
- {
+{
QuickData * mtbi1=(QuickData *)*((QuickData ** )vmtbi1);
QuickData * mtbi2=(QuickData *)*((QuickData ** )vmtbi2);
if (mtbi1==NULL || mtbi2==NULL) return (mtbi1-mtbi2);
return mtbi1->dwPos-mtbi2->dwPos;
- }
+}
int sstOpSortButtons(const void * vmtbi1, const void * vmtbi2)
- {
+{
ButtonData * mtbi1=(ButtonData *)*((ButtonData ** )vmtbi1);
ButtonData * mtbi2=(ButtonData *)*((ButtonData ** )vmtbi2);
if (mtbi1==NULL || mtbi2==NULL) return (mtbi1-mtbi2);
return mtbi1->dwOPPos-mtbi2->dwOPPos;
- }
+}
void li_ListDestruct(SortedList *pList, ItemDestuctor pItemDestructor)
- {
+{
int i=0;
if (!pList) return;
for (i=0; i<pList->realCount; i++) pItemDestructor(pList->items[i]);
List_Destroy(pList);
mir_free(pList);
- }
+}
void li_RemoveDestruct(SortedList *pList, int index, ItemDestuctor pItemDestructor)
- {
+{
if (index>=0 && index<pList->realCount)
- {
+ {
pItemDestructor(pList->items[index]);
List_Remove(pList, index);
- }
}
+}
void li_RemovePtrDestruct(SortedList *pList, void * ptr, ItemDestuctor pItemDestructor)
- {
+{
if (List_RemovePtr(pList, ptr))
pItemDestructor(ptr);
- }
+}
void li_SortList(SortedList *pList, FSortFunc pSortFunct)
- {
+{
FSortFunc pOldSort=pList->sortFunc;
int i;
if (!pSortFunct) pSortFunct=pOldSort;
pList->sortFunc=NULL;
for (i=0; i<pList->realCount-1; i++)
if (pOldSort(pList->items[i],pList->items[i+1])<0)
- {
+ {
void * temp=pList->items[i];
pList->items[i]=pList->items[i+1];
pList->items[i+1]=temp;
i--;
if (i>0) i--;
- }
+ }
pList->sortFunc=pOldSort;
- }
+}
void li_ZeroQuickList(SortedList *pList)
- {
+{
int i;
for (i=0; i<pList->realCount; i++)
- {
- QuickData * qd=(QuickData *)pList->items[i];
- qd->dwPos=0;
- qd->bIsService=0;
- qd->ptszValue=NULL;
- qd->ptszValueName=NULL;
- List_Remove(pList, i);
- i--;
- }
+ {
+ QuickData * qd=(QuickData *)pList->items[i];
+ qd->dwPos=0;
+ qd->bIsService=0;
+ qd->ptszValue=NULL;
+ qd->ptszValueName=NULL;
+ List_Remove(pList, i);
+ i--;
}
+}
static void listdestructor(void * input)
- {
+{
ButtonData * cbdi=(ButtonData *)input;
-
+
if(cbdi->pszName!=cbdi->pszOpName)
- {
+ {
if(cbdi->pszOpName)
mir_free(cbdi->pszOpName);
if(cbdi->pszName)
mir_free(cbdi->pszName);
- }
+ }
else if(cbdi->pszName)
- mir_free(cbdi->pszName);
+ mir_free(cbdi->pszName);
if(cbdi->pszValue!=cbdi->pszOpValue)
- {
+ {
if(cbdi->pszOpValue)
mir_free(cbdi->pszOpValue);
if(cbdi->pszValue)
mir_free(cbdi->pszValue);
- }
+ }
else if(cbdi->pszValue)
- mir_free(cbdi->pszValue);
+ mir_free(cbdi->pszValue);
mir_free(cbdi);
- }
+}
void RemoveMenuEntryNode(SortedList *pList, int index)
- {
- li_RemoveDestruct(pList,index,listdestructor);
- }
+{
+ li_RemoveDestruct(pList,index,listdestructor);
+}
void DestroyButton(int listnum)
- {
+{
int i=listnum;
ListData* ld=ButtonsList[listnum];
-
+
if(ld->ptszButtonName) mir_free(ld->ptszButtonName);
if(ld->ptszOPQValue!=ld->ptszQValue)
if(ld->ptszOPQValue) mir_free(ld->ptszOPQValue);
-
+
if (ld->ptszQValue) mir_free(ld->ptszQValue);
li_ListDestruct((SortedList*)ld->sl,listdestructor);
-
+
mir_free(ld);
ButtonsList[i]=NULL;
while(ButtonsList[i+1])
{
- ButtonsList[i]=ButtonsList[i+1];
- ButtonsList[i+1]=NULL;
- i++;
+ ButtonsList[i]=ButtonsList[i+1];
+ ButtonsList[i+1]=NULL;
+ i++;
}
}
void SaveModuleSettings(int buttonnum,ButtonData* bd)
- {
+{
char szMEntry[256]={'\0'};
mir_snprintf(szMEntry,255,"EntryName_%u_%u",buttonnum,bd->dwPos);
@@ -189,10 +187,10 @@ void SaveModuleSettings(int buttonnum,ButtonData* bd)
mir_snprintf(szMEntry,255,"EntryIsServiceName_%u_%u",buttonnum,bd->dwPos);
DBWriteContactSettingByte(NULL, PLGNAME,szMEntry,bd->bIsServName);
- }
+}
void CleanSettings(int buttonnum,int from)
- {
+{
char szMEntry[256]={'\0'};
DBVARIANT dbv = {0};
if(from==-1){
@@ -202,7 +200,7 @@ void CleanSettings(int buttonnum,int from)
DBDeleteContactSetting(NULL, PLGNAME,szMEntry);
mir_snprintf(szMEntry,255,"RCEntryIsServiceName_%u",buttonnum);
DBDeleteContactSetting(NULL, PLGNAME,szMEntry);
- }
+ }
mir_snprintf(szMEntry,255,"EntryName_%u_%u",buttonnum,from);
while(!DBGetContactSettingTString(NULL, PLGNAME,szMEntry,&dbv)) {
@@ -217,12 +215,12 @@ void CleanSettings(int buttonnum,int from)
DBDeleteContactSetting(NULL, PLGNAME,szMEntry);
mir_snprintf(szMEntry,255,"EntryName_%u_%u",buttonnum,++from);
- }
- DBFreeVariant(&dbv);
}
+ DBFreeVariant(&dbv);
+}
BYTE getEntryByte(int buttonnum,int entrynum,BOOL mode)
- {
+{
char szMEntry[256]={'\0'};
if (mode==0)
mir_snprintf(szMEntry,255,"EntryToQMenu_%u_%u",buttonnum,entrynum);
@@ -233,52 +231,64 @@ BYTE getEntryByte(int buttonnum,int entrynum,BOOL mode)
else if (mode==3)
mir_snprintf(szMEntry,255,"RCEntryIsServiceName_%u",buttonnum);
return DBGetContactSettingByte(NULL, PLGNAME,szMEntry, 0);
- }
+}
-DWORD BalanceButtons(int buttonsWas,int buttonsNow)
- {
- if (ServiceExists(MS_BB_ADDBUTTON))
- {
- BBButton bb={0};
- bb.cbSize=sizeof(BBButton);
- bb.pszModuleName=PLGNAME;
-
- while(buttonsWas>(buttonsNow))
- {
- bb.dwButtonID=--buttonsWas;
- CallService(MS_BB_REMOVEBUTTON,0,(LPARAM)&bb);
- }
- while (buttonsWas<(buttonsNow))
- {
- if (ServiceExists(MS_BB_ADDBUTTON))
- {
- char iconname[20]={'\0'};
- mir_snprintf(iconname,SIZEOF(iconname),"QMessagesButton_%u",buttonsWas);
- bb.bbbFlags=BBBF_ISIMBUTTON|BBBF_ISCHATBUTTON|BBBF_ISLSIDEBUTTON;
- bb.dwButtonID=buttonsWas++;
- bb.dwDefPos=300+buttonsWas;
- bb.hIcon = (HANDLE)AddIcon(hIcon, iconname, iconname);
+static HANDLE AddIcon(char* szIcoName)
+{
+ TCHAR tszPath[MAX_PATH];
+ GetModuleFileName(hinstance, tszPath, SIZEOF(tszPath));
+
+ SKINICONDESC sid = { sizeof(sid) };
+ sid.flags = SIDF_PATH_TCHAR;
+ sid.pszSection = "Quick Messages";
+ sid.cx = sid.cy = 16;
+ sid.pszDescription = szIcoName;
+ sid.pszName = szIcoName;
+ sid.ptszDefaultFile = tszPath;
+ sid.iDefaultIndex = -IDI_QICON;
+ return Skin_AddIcon(&sid);
+}
+
+DWORD BalanceButtons(int buttonsWas, int buttonsNow)
+{
+ if ( !ServiceExists(MS_BB_ADDBUTTON)) {
+ BBButton bb = { sizeof(bb) };
+ bb.pszModuleName = PLGNAME;
+
+ while (buttonsWas > buttonsNow) {
+ bb.dwButtonID = --buttonsWas;
+ CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bb);
+ }
+
+ while (buttonsWas < buttonsNow) {
+ if (ServiceExists(MS_BB_ADDBUTTON)) {
+ char iconname[20];
+ mir_snprintf(iconname, SIZEOF(iconname), "QMessagesButton_%u", buttonsWas);
+ bb.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON;
+ bb.dwButtonID = buttonsWas++;
+ bb.dwDefPos = 300+buttonsWas;
+ bb.hIcon = AddIcon(iconname);
CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bb);
- }
}
}
- return buttonsNow;
}
+ return buttonsNow;
+}
void InitButtonsList()
- {
+{
int i,j,k=0;
QuickList=List_Create(0,1);
for(i=0;i<g_iButtonsCount;i++)
- {
+ {
TCHAR* pszBName=NULL;
ListData* ld=NULL;
if (!(pszBName=getMenuEntry(i,0,3))) {
g_iButtonsCount=i;
DBWriteContactSettingByte(NULL, PLGNAME,"ButtonsCount", (BYTE)g_iButtonsCount);
break;}
-
+
ld = (ListData *)mir_alloc(sizeof(ListData));
ButtonsList[i]=ld;
ld->sl=List_Create(0,1);
@@ -288,10 +298,10 @@ void InitButtonsList()
ld->dwOPFlags=0;
ld->bIsServName=ld->bIsOpServName=getEntryByte(i,0,3);
for(j=0;;j++)
- {
+ {
TCHAR* pszEntry=NULL;
ButtonData *bd=NULL;
-
+
if (!(pszEntry=getMenuEntry(i,j,0)))
break;
@@ -310,35 +320,34 @@ void InitButtonsList()
qd->ptszValue=bd->pszValue;
qd->ptszValueName=bd->pszName;
List_InsertPtr(QuickList,qd);
- }
- List_InsertPtr((SortedList*)ld->sl,bd);
}
+ List_InsertPtr((SortedList*)ld->sl,bd);
}
-
}
+}
void DestructButtonsList()
{
int i=0;
-// for ( i=0; i < g_iButtonsCount; i++ )
-while(ButtonsList[i])
- {
+ // for ( i=0; i < g_iButtonsCount; i++ )
+ while(ButtonsList[i])
+ {
li_ListDestruct(ButtonsList[i]->sl,listdestructor);
mir_free(ButtonsList[i]->ptszButtonName);
if(ButtonsList[i]->ptszOPQValue!=ButtonsList[i]->ptszQValue)
if (ButtonsList[i]->ptszOPQValue) mir_free(ButtonsList[i]->ptszOPQValue);
if (ButtonsList[i]->ptszQValue) mir_free(ButtonsList[i]->ptszQValue);
- i++;
+ i++;
}
-if(QuickList)
+ if(QuickList)
{
- li_ZeroQuickList(QuickList);
- List_Destroy(QuickList);
+ li_ZeroQuickList(QuickList);
+ List_Destroy(QuickList);
}
}
TCHAR* getMenuEntry(int buttonnum,int entrynum,BYTE mode)
- {
+{
TCHAR* buffer=NULL;
char szMEntry[256]={'\0'};
DBVARIANT dbv = {0};
@@ -356,74 +365,56 @@ TCHAR* getMenuEntry(int buttonnum,int entrynum,BYTE mode)
DBGetContactSettingTString(NULL, PLGNAME,szMEntry, &dbv);
if(dbv.ptszVal&&_tcslen(dbv.ptszVal))
- {
+ {
buffer=mir_tstrdup(dbv.ptszVal);
DBFreeVariant(&dbv);
- }
-
- return buffer;
}
-
-int AddIcon(HICON icon, char *name, char *description)
-{
- SKINICONDESC sid = {0};
- sid.cbSize = sizeof(SKINICONDESC);
- sid.pszSection = "Quick Messages";
- sid.cx = sid.cy = 16;
- sid.pszDescription = description;
- sid.pszName = name;
- sid.hDefaultIcon = icon;
-
- return (int)Skin_AddIcon(&sid);
+ return buffer;
}
int RegisterCustomButton(WPARAM wParam,LPARAM lParam)
- {
- if (ServiceExists(MS_BB_ADDBUTTON))
- {
- int i;
- for(i=0;i<g_iButtonsCount;i++)
- {
- BBButton bbd={0};
- ListData* ld=ButtonsList[i];
- char iconname[20]={'\0'};
- mir_snprintf(iconname,SIZEOF(iconname),"QMessagesButton_%u",i);
-
- bbd.cbSize=sizeof(BBButton);
- bbd.bbbFlags=BBBF_ISIMBUTTON|BBBF_ISCHATBUTTON|BBBF_ISLSIDEBUTTON;
- bbd.dwButtonID=i;
- bbd.dwDefPos=320+i;
- bbd.hIcon=(HANDLE)AddIcon(hIcon, iconname, iconname);
- bbd.pszModuleName=PLGNAME;
- bbd.ptszTooltip=ld->ptszButtonName;
- CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
- }
- return 0;
- }
- return 1;
+{
+ if ( !ServiceExists(MS_BB_ADDBUTTON))
+ return 1;
+
+ for (int i=0; i < g_iButtonsCount; i++) {
+ ListData* ld = ButtonsList[i];
+
+ char iconname[20];
+ mir_snprintf(iconname, SIZEOF(iconname), "QMessagesButton_%u", i);
+
+ BBButton bbd = { sizeof(bbd) };
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON;
+ bbd.dwButtonID = i;
+ bbd.dwDefPos = 320+i;
+ bbd.hIcon = AddIcon(iconname);
+ bbd.pszModuleName = PLGNAME;
+ bbd.ptszTooltip = ld->ptszButtonName;
+ CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
}
+ return 0;
+}
TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptszClip,int QVSize,int TextSize ,int ClipSize)
- {
+{
int i=0,iOffset=0,iCount=0;
TCHAR* tempPointer=NULL;
TCHAR* ptszQValue=_tcsdup(ptszQValIn);
TCHAR* tempQValue=ptszQValue;
TCHAR varstr=_T('%');
-
- if(TextSize&&ptszText[TextSize-1]=='\0') TextSize--;
- if(ClipSize&&ptszClip[ClipSize-1]=='\0') ClipSize--;
+
+ if(TextSize&&ptszText[TextSize-1]=='\0') TextSize--;
+ if(ClipSize&&ptszClip[ClipSize-1]=='\0') ClipSize--;
if (!_tcschr(ptszQValue,varstr))
return ptszQValue;
- while(ptszQValue[i])
- {
+ while(ptszQValue[i]) {
if(ptszQValue[i]=='%') {
- switch(ptszQValue[i+1])
+ switch(ptszQValue[i+1]) {
+ case 't':
{
- case 't':{
TCHAR* p=NULL;
p = (TCHAR *)realloc(tempQValue, (QVSize + TextSize+1)*sizeof(TCHAR));
if(p){
@@ -432,23 +423,24 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz
tempQValue=ptszQValue=p;
tempPointer = (TCHAR *)memmove(ptszQValue + i + TextSize, ptszQValue + i + 2, (QVSize - i - 1)*sizeof(TCHAR));
-
+
if(TextSize) memcpy(ptszQValue+i, ptszText, TextSize*sizeof(TCHAR));
-
- QVSize+=(TextSize-2);
-
- ptszQValue[QVSize]='\0';
-
+
+ QVSize+=(TextSize-2);
+
+ ptszQValue[QVSize]='\0';
+
if (!_tcschr(ptszQValue,varstr))
return ptszQValue;
ptszQValue=tempPointer;
iOffset+=TextSize-1;
i=-1;
- }
+ }
}break;
- case 'c':{
+ case 'c':
+ {
TCHAR* p=NULL;
p = (TCHAR *)realloc(tempQValue, (QVSize + ClipSize + 1)*sizeof(TCHAR));
if(p){
@@ -460,17 +452,18 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz
QVSize+=(ClipSize-2);
ptszQValue[QVSize]='\0';
-
+
if (!_tcschr(ptszQValue,varstr))
return ptszQValue;
ptszQValue=tempPointer;
iOffset+=ClipSize-1;
i=-1;
- }
+ }
}break;
- case 'P':{
+ case 'P':
+ {
TCHAR* p=NULL;
int NameLenght=0;
TCHAR* ptszName=NULL;
@@ -497,10 +490,11 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz
ptszQValue=tempPointer;
iOffset+=NameLenght-1;
i=-1;
- }
- }break;
+ }
+ }break;
- case 'n':{
+ case 'n':
+ {
TCHAR* p=NULL;
int NameLenght=0;
TCHAR* ptszName=NULL;
@@ -526,9 +520,10 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz
ptszQValue=tempPointer;
iOffset+=NameLenght-1;
i=-1;
- }
- }break;
- case 'F':{
+ }
+ }break;
+ case 'F':
+ {
TCHAR* p=NULL;
int NameLenght=0;
TCHAR* ptszName=NULL;
@@ -543,7 +538,7 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz
if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)&&ci.pszVal){
NameLenght=(int)_tcslen(ci.pszVal);
ptszName=ci.pszVal;
- }
+ }
p = (TCHAR *)realloc(tempQValue, (QVSize + NameLenght + 1)*sizeof(TCHAR));
if(p){
i=iOffset;
@@ -563,9 +558,10 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz
ptszQValue=tempPointer;
iOffset+=NameLenght-1;
i=-1;
- }
- }break;
- case 'L':{
+ }
+ }break;
+ case 'L':
+ {
TCHAR* p=NULL;
int NameLenght=0;
TCHAR* ptszName=NULL;
@@ -580,7 +576,7 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz
if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)&&ci.pszVal){
NameLenght=(int)_tcslen(ci.pszVal);
ptszName=ci.pszVal;
- }
+ }
p = (TCHAR *)realloc(tempQValue, (QVSize + NameLenght + 1)*sizeof(TCHAR));
if(p){
i=iOffset;
@@ -598,12 +594,12 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz
ptszQValue=tempPointer;
iOffset+=NameLenght-1;
i=-1;
- }
- }break;
- }
+ }
+ }break;
}
+ }
iOffset++;
i++;
- }
+ }
return ptszQValue;
- } \ No newline at end of file
+}
diff --git a/plugins/QuickMessages/src/main.cpp b/plugins/QuickMessages/src/main.cpp
index e13d075041..7fba5f8e4e 100644
--- a/plugins/QuickMessages/src/main.cpp
+++ b/plugins/QuickMessages/src/main.cpp
@@ -20,13 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "quickmessages.h"
HINSTANCE hinstance;
+int hLangpack;
WNDPROC mainProc;
-HANDLE hEventCBButtonPressed, hEventCBInit,hEventInputMenu, hEventDbOptionsInit, hEventDbPluginsLoaded,
-hEventDbPreShutdown;
-HICON hIcon;
-
int g_iButtonsCount=0;
int g_bShutDown=0;
int g_bStartup=0;
@@ -34,9 +31,6 @@ BOOL g_bRClickAuto=0;
BOOL g_bLClickAuto=0;
BOOL g_bQuickMenu=0;
-
-int hLangpack;
-
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
MODULENAME,
@@ -53,16 +47,8 @@ PLUGININFOEX pluginInfo = {
int PreShutdown(WPARAM wparam,LPARAM lparam)
{
- g_bShutDown=1;
+ g_bShutDown = 1;
DestructButtonsList();
-
- if(hEventCBButtonPressed) UnhookEvent(hEventCBButtonPressed);
- if(hEventCBInit) UnhookEvent(hEventCBInit);
- if(hEventInputMenu) UnhookEvent(hEventInputMenu);
- UnhookEvent(hEventDbPluginsLoaded);
- UnhookEvent(hEventDbOptionsInit);
- UnhookEvent(hEventDbPreShutdown);
-
return 0;
}
@@ -74,28 +60,28 @@ static int InputMenuPopup(WPARAM wParam,LPARAM lParam)
if(mwpd->uFlags==MSG_WINDOWPOPUP_LOG||!g_bQuickMenu||!QuickList->realCount) return 0;
if(mwpd->uType==MSG_WINDOWPOPUP_SHOWING)
- {
+ {
hSubMenu = CreatePopupMenu();
InsertMenu((HMENU)mwpd->hMenu,6,MF_STRING|MF_POPUP|MF_BYPOSITION,(UINT_PTR)hSubMenu,TranslateT("Quick Messages"));
InsertMenu((HMENU)mwpd->hMenu,7,MF_SEPARATOR|MF_BYPOSITION,0,0);
qsort(QuickList->items,QuickList->realCount,sizeof(QuickData *),sstQuickSortButtons);
for(i=0;i<QuickList->realCount;i++)
- {
+ {
QuickData* qd= (QuickData *)QuickList->items[i];
if(qd->fEntryType&QMF_EX_SEPARATOR)
AppendMenu(hSubMenu,MF_SEPARATOR,0,NULL);
else
AppendMenu(hSubMenu,MF_STRING,qd->dwPos+254,qd->ptszValueName);
- }
}
+ }
else if(mwpd->uType==MSG_WINDOWPOPUP_SELECTED&&mwpd->selection>=254)
- {
+ {
for(i=0;i<QuickList->realCount;i++)
- {
+ {
QuickData* qd= (QuickData *)QuickList->items[i];
if ((qd->dwPos+254)==mwpd->selection)
- {
+ {
CHARRANGE cr;
UINT textlenght=0;
TCHAR* pszText=NULL;
@@ -116,25 +102,25 @@ static int InputMenuPopup(WPARAM wParam,LPARAM lParam)
pszCBText=mir_tstrdup(chBuffer);
GlobalUnlock(hData);
CloseClipboard();
- }
}
+ }
SendMessage(mwpd->hwnd, EM_EXGETSEL, 0, (LPARAM)&cr);
textlenght=cr.cpMax-cr.cpMin;
if(textlenght)
- {
+ {
pszText = (TCHAR *)mir_alloc((textlenght+10)*sizeof(TCHAR));
ZeroMemory(pszText,(textlenght+10)*sizeof(TCHAR));
SendMessage(mwpd->hwnd,EM_GETSELTEXT, 0, (LPARAM)pszText);
- }
+ }
if(qd->ptszValue){
- ptszQValue=ParseString(mwpd->hContact,qd->ptszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(qd->ptszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
+ ptszQValue=ParseString(mwpd->hContact,qd->ptszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(qd->ptszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
if ((bIsService=qd->bIsService)&&ptszQValue)
CallService(mir_u2a(ptszQValue),(WPARAM)mwpd->hContact,0);
- }
+ }
if(ptszQValue)
SendMessage(mwpd->hwnd, EM_REPLACESEL, TRUE, (LPARAM)ptszQValue);
@@ -143,10 +129,10 @@ static int InputMenuPopup(WPARAM wParam,LPARAM lParam)
if(ptszQValue) free(ptszQValue);
if(pszCBText) mir_free(pszCBText);
break;
- }
}
- return 1;
}
+ return 1;
+ }
return 0;
}
@@ -191,11 +177,8 @@ static int CustomButtonPressed(WPARAM wParam,LPARAM lParam)
pszCBText=mir_tstrdup(chBuffer);
GlobalUnlock(hData);
CloseClipboard();
- }
}
-
-
-
+ }
qsort(sl->items,sl->realCount,sizeof(ButtonData *),sstSortButtons);
@@ -207,11 +190,11 @@ static int CustomButtonPressed(WPARAM wParam,LPARAM lParam)
textlenght=cr.cpMax-cr.cpMin;
if(textlenght)
- {
+ {
pszText = (TCHAR *)mir_alloc((textlenght+10)*sizeof(TCHAR));
ZeroMemory(pszText,(textlenght+10)*sizeof(TCHAR));
SendMessage(hEdit,EM_GETSELTEXT, 0, (LPARAM)pszText);
- }
+ }
if(cbcd->flags&BBCF_RIGHTBUTTON)
state=1;
@@ -220,118 +203,105 @@ static int CustomButtonPressed(WPARAM wParam,LPARAM lParam)
else
state=3;
+ switch(state) {
+ case 1:
+ if(ButtonsList[cbcd->dwButtonId]->ptszQValue)
+ ptszQValue = ParseString(cbcd->hContact,ButtonsList[cbcd->dwButtonId]->ptszQValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(ButtonsList[cbcd->dwButtonId]->ptszQValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
+ if ((bIsService = ButtonsList[cbcd->dwButtonId]->bIsServName) && ptszQValue)
+ CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ break;
- switch(state)
+ case 2:
{
- case 1:
- if(ButtonsList[cbcd->dwButtonId]->ptszQValue)
- ptszQValue=ParseString(cbcd->hContact,ButtonsList[cbcd->dwButtonId]->ptszQValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(ButtonsList[cbcd->dwButtonId]->ptszQValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
- if ((bIsService=ButtonsList[cbcd->dwButtonId]->bIsServName)&&ptszQValue)
-
- CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ ButtonData *bd = (ButtonData *)sl->items[0];
+ if(bd && bd->pszValue){
+ ptszQValue = ParseString(cbcd->hContact,bd->pszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(bd->pszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
+ if ((bIsService = bd->bIsServName)&&ptszQValue)
+ CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ }
+ }
+ break;
- break;
- case 2:
- {
- ButtonData * bd=NULL;
- bd=(ButtonData *)sl->items[0];
- if(bd&&bd->pszValue){
- ptszQValue=ParseString(cbcd->hContact,bd->pszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(bd->pszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
- if ((bIsService=bd->bIsServName)&&ptszQValue)
+ case 3:
+ int res=0;
+ int menunum;
+ ButtonData * bd=NULL;
+ HMENU hMenu=NULL,hSubMenu=NULL;
+ BOOL bSetPopUpMark=FALSE;
- CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ if(g_iButtonsCount){
+ hMenu = CreatePopupMenu();
+ }
+ else break;
+ for(menunum=0;menunum<sl->realCount;menunum++)
+ {
+ bd=(ButtonData *)sl->items[menunum];
+ if(bd->dwOPFlags&QMF_NEW)
+ continue;
- }
+ bSetPopUpMark=FALSE;
+ if(bd->pszValue==0&&bd->fEntryType==0)
+ {
+ hSubMenu = CreatePopupMenu();
+ bSetPopUpMark=TRUE;
}
- break;
- case 3:{
- int res=0;
- int menunum;
- ButtonData * bd=NULL;
- HMENU hMenu=NULL,hSubMenu=NULL;
- BOOL bSetPopUpMark=FALSE;
-
- if(g_iButtonsCount){
- hMenu = CreatePopupMenu();
- }
- else break;
- for(menunum=0;menunum<sl->realCount;menunum++)
- {
- bd=(ButtonData *)sl->items[menunum];
- if(bd->dwOPFlags&QMF_NEW)
- continue;
-
- bSetPopUpMark=FALSE;
- if(bd->pszValue==0&&bd->fEntryType==0)
- {
- hSubMenu = CreatePopupMenu();
- bSetPopUpMark=TRUE;
- }
-
- if(bd->pszValue&&bd->fEntryType==0)
- hSubMenu=NULL;
- if(bd->fEntryType&QMF_EX_SEPARATOR)
- AppendMenu((HMENU)((hSubMenu&&!bSetPopUpMark)?hSubMenu:hMenu),MF_SEPARATOR,0,NULL);
- else
- AppendMenu((HMENU)((hSubMenu&&!bSetPopUpMark)?hSubMenu:hMenu),
- MF_STRING|(bSetPopUpMark?MF_POPUP:0),
- (bSetPopUpMark?(UINT_PTR)hSubMenu:(menunum+1)), bd->pszName);
- }
+ if(bd->pszValue&&bd->fEntryType==0)
+ hSubMenu=NULL;
- res = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL);
- if(res==0) break;
-
- bd= (ButtonData *)sl->items[res-1];
- bCTRL=(GetKeyState(VK_CONTROL)&0x8000)?1:0;
- if(bd->pszValue){
- ptszQValue=ParseString(cbcd->hContact,bd->pszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(bd->pszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
- if ((bIsService=bd->bIsServName)&&ptszQValue)
+ if(bd->fEntryType&QMF_EX_SEPARATOR)
+ AppendMenu((HMENU)((hSubMenu&&!bSetPopUpMark)?hSubMenu:hMenu),MF_SEPARATOR,0,NULL);
+ else
+ AppendMenu((HMENU)((hSubMenu&&!bSetPopUpMark)?hSubMenu:hMenu),
+ MF_STRING|(bSetPopUpMark?MF_POPUP:0),
+ (bSetPopUpMark?(UINT_PTR)hSubMenu:(menunum+1)), bd->pszName);
+ }
- CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
+ res = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL);
+ if(res==0) break;
- }
- }break;
+ bd= (ButtonData *)sl->items[res-1];
+ bCTRL=(GetKeyState(VK_CONTROL)&0x8000)?1:0;
+ if(bd->pszValue){
+ ptszQValue=ParseString(cbcd->hContact,bd->pszValue,pszText?pszText:_T(""),pszCBText?pszCBText:_T(""),(int)_tcslen(bd->pszValue),textlenght,pszCBText?(int)_tcslen(pszCBText):0);
+ if ((bIsService=bd->bIsServName)&&ptszQValue)
+ CallService(mir_u2a(ptszQValue),(WPARAM)cbcd->hContact,0);
}
+ break;
+ }
-
- if(ptszQValue){
- if (!bIsService){
+ if(ptszQValue) {
+ if (!bIsService) {
SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)ptszQValue);
if ((g_bLClickAuto&&state!=1)||(g_bRClickAuto&&state==1)||cbcd->flags&BBCF_CONTROLPRESSED||bCTRL)
SendMessage(cbcd->hwndFrom, WM_COMMAND,IDOK,0);
}
free(ptszQValue);
- }
+ }
- if(pszText) mir_free(pszText);
- if(pszCBText) mir_free(pszCBText);
+ mir_free(pszText);
+ mir_free(pszCBText);
return 1;
}
-
static int PluginInit(WPARAM wparam,LPARAM lparam)
{
- g_bStartup=1;
- hEventDbOptionsInit=HookEvent(ME_OPT_INITIALISE,OptionsInit);
- hEventCBButtonPressed=HookEvent(ME_MSG_BUTTONPRESSED,CustomButtonPressed);
- hEventCBInit=HookEvent(ME_MSG_TOOLBARLOADED,RegisterCustomButton);
-
- hEventInputMenu=HookEvent(ME_MSG_WINDOWPOPUP,InputMenuPopup);
-
-
- g_bRClickAuto=DBGetContactSettingByte(NULL,PLGNAME,"RClickAuto",0);
- g_bLClickAuto=DBGetContactSettingByte(NULL,PLGNAME,"LClickAuto",0);
- g_iButtonsCount=DBGetContactSettingByte(NULL, PLGNAME,"ButtonsCount", 0);
- g_bQuickMenu=DBGetContactSettingByte(NULL, PLGNAME,"QuickMenu", 1);
+ g_bStartup = 1;
+ HookEvent(ME_OPT_INITIALISE, OptionsInit);
+ HookEvent(ME_MSG_BUTTONPRESSED, CustomButtonPressed);
+ HookEvent(ME_MSG_TOOLBARLOADED, RegisterCustomButton);
+ HookEvent(ME_MSG_WINDOWPOPUP, InputMenuPopup);
- hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_QICON));
+ g_bRClickAuto = DBGetContactSettingByte(NULL,PLGNAME,"RClickAuto",0);
+ g_bLClickAuto = DBGetContactSettingByte(NULL,PLGNAME,"LClickAuto",0);
+ g_iButtonsCount = DBGetContactSettingByte(NULL, PLGNAME,"ButtonsCount", 0);
+ g_bQuickMenu = DBGetContactSettingByte(NULL, PLGNAME,"QuickMenu", 1);
InitButtonsList();
- g_bStartup=0;
+ g_bStartup = 0;
return 0;
}
@@ -347,17 +317,15 @@ extern "C" __declspec(dllexport) int Unload(void)
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
{
- hinstance=hinst;
+ hinstance = hinst;
return 1;
}
extern "C" __declspec(dllexport) int Load(void)
{
-
-
mir_getLP(&pluginInfo);
- hEventDbPluginsLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,PluginInit);
- hEventDbPreShutdown=HookEvent(ME_SYSTEM_PRESHUTDOWN,PreShutdown);
+ HookEvent(ME_SYSTEM_MODULESLOADED,PluginInit);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN,PreShutdown);
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/QuickMessages/src/quickmessages.h b/plugins/QuickMessages/src/quickmessages.h
index f236b4175f..af7c4a5879 100644
--- a/plugins/QuickMessages/src/quickmessages.h
+++ b/plugins/QuickMessages/src/quickmessages.h
@@ -38,6 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "m_icolib.h"
#include "m_message.h"
#include "m_contacts.h"
+#include "win2k.h"
#include "Utils.h"
#include "m_msg_buttonsbar.h"
@@ -48,7 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PLGNAME "QuickMessages"
extern HINSTANCE hinstance;
-extern HICON hIcon;
+extern HANDLE hIcolib;
extern ListData* ButtonsList[100];
extern SortedList* QuickList;
extern BOOL g_bRClickAuto;
@@ -56,29 +57,16 @@ extern BOOL g_bLClickAuto;
extern BOOL g_bQuickMenu;
extern int g_iButtonsCount;
-//#define MIIM_STRING 0x00000040
-
-
-
-int AddIcon(HICON icon, char *name, char *description);
int OptionsInit(WPARAM,LPARAM);
-
-#define IDC_MESSAGE 1002
-#define IDC_CHATMESSAGE 1009
-
-#define SIZEOF(X)(sizeof(X)/sizeof(X[0]))
-
+#define IDC_MESSAGE 1002
+#define IDC_CHATMESSAGE 1009
#define QMESSAGES_NAME "quickmessages"
-
#define QMESSAGES_VERSION_URL "http://miranda.radicaled.ru/public/updater/quickmessages.txt"
-
#define QMESSAGES_CHAGELOG_URL "http://miranda.radicaled.ru/public/quickmessages/changelog_en.txt"
-
#define QMESSAGES_UPDATE_URL "http://miranda.radicaled.ru/public/quickmessages/"QMESSAGES_NAME".zip"
-
#define QMESSAGES_UPDATE_URL "http://miranda.radicaled.ru/public/quickmessages/"QMESSAGES_NAME".zip"
#define QMESSAGES_VERSION_PREFIX "QuickMessages "