summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src/Main.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-07-29 21:18:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-07-29 21:18:27 +0000
commit1271802f514d41e8e06df7714d1f1e4a430b417b (patch)
tree5bd4ef52613333cba786f1246414e422a5e4c95a /plugins/SendScreenshotPlus/src/Main.cpp
parent14d0ed2003485ebf19d45672b065a7dd2bf5274a (diff)
- warning fixes;
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@14757 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus/src/Main.cpp')
-rw-r--r--plugins/SendScreenshotPlus/src/Main.cpp225
1 files changed, 117 insertions, 108 deletions
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp
index 4474b47732..717cdfa04c 100644
--- a/plugins/SendScreenshotPlus/src/Main.cpp
+++ b/plugins/SendScreenshotPlus/src/Main.cpp
@@ -37,50 +37,54 @@ HANDLE g_hNetlibUser=0;//!< Netlib Register User
FI_INTERFACE* FIP=NULL;
int hLangpack;//Miranda NG langpack used by translate functions, filled by mir_getLP()
-IconItem ICONS[ICO_END_]={
- {LPGEN("Main Icon"),"main",IDI_MAIN,32},
- {LPGEN("Main Icon"),"mainxs",IDI_MAIN},
- {LPGEN("Target Cursor"),"target",IDI_TARGET,32},
- {LPGEN("Target Desktop"),"monitor",IDI_MONITOR,32},
+IconItem ICONS[ICO_END_] =
+{
+ { LPGEN("Main Icon"), "main", IDI_MAIN, 32 },
+ { LPGEN("Main Icon"), "mainxs", IDI_MAIN },
+ { LPGEN("Target Cursor"), "target", IDI_TARGET, 32 },
+ { LPGEN("Target Desktop"), "monitor", IDI_MONITOR, 32 },
};
-IconItem ICONS_BTN[ICO_BTN_END_]={
- {LPGEN("Help"),"help",IDI_HELP},
- {LPGEN("Open Folder"),"folder",IDI_FOLDER},
- {LPGEN("Description off"),"desc",IDI_DESC},
- {LPGEN("Description on"),"descon",IDI_DESCON},
- {LPGEN("Delete off"),"del",IDI_DEL},
- {LPGEN("Delete on"),"delon",IDI_DELON},
- {LPGEN("Prev"),"arrowl",IDI_ARROWL},
- {LPGEN("Next"),"arrowr",IDI_ARROWR},
- {LPGEN("Update"),"update",IDI_UPDATE},
- {LPGEN("OK"),"ok",IDI_OK},
- {LPGEN("Cancel"),"cancel",IDI_CANCEL},
-// {LPGEN("Apply"),"apply",IDI_APPLY},
- {LPGEN("Edit"),"edit",IDI_EDIT},
- {LPGEN("Edit on"),"editon",IDI_EDITON},
- {LPGEN("Copy"),"copy",IDI_COPY},
- {LPGEN("BBC"),"bbc",IDI_BBC},
- {LPGEN("BBC link"),"bbclnk",IDI_BBC2},
- {LPGEN("Down arrow"),"downarrow",IDI_DOWNARROW},
+
+IconItem ICONS_BTN[ICO_BTN_END_] =
+{
+ { LPGEN("Help"), "help", IDI_HELP },
+ { LPGEN("Open Folder"), "folder", IDI_FOLDER },
+ { LPGEN("Description off"), "desc", IDI_DESC },
+ { LPGEN("Description on"), "descon", IDI_DESCON },
+ { LPGEN("Delete off"), "del", IDI_DEL },
+ { LPGEN("Delete on"), "delon", IDI_DELON },
+ { LPGEN("Prev"), "arrowl", IDI_ARROWL },
+ { LPGEN("Next"), "arrowr", IDI_ARROWR },
+ { LPGEN("Update"), "update", IDI_UPDATE },
+ { LPGEN("OK"), "ok", IDI_OK },
+ { LPGEN("Cancel"), "cancel", IDI_CANCEL },
+ // {LPGEN("Apply"),"apply",IDI_APPLY},
+ { LPGEN("Edit"), "edit", IDI_EDIT },
+ { LPGEN("Edit on"), "editon", IDI_EDITON },
+ { LPGEN("Copy"), "copy", IDI_COPY },
+ { LPGEN("BBC"), "bbc", IDI_BBC },
+ { LPGEN("BBC link"), "bbclnk", IDI_BBC2 },
+ { LPGEN("Down arrow"), "downarrow", IDI_DOWNARROW },
};
-static HANDLE m_hFolderScreenshot=0;
-TCHAR* GetCustomPath() {
+static HANDLE m_hFolderScreenshot = 0;
+TCHAR* GetCustomPath()
+{
TCHAR* pszPath = Utils_ReplaceVarsT(_T("%miranda_userdata%\\Screenshots"));
- if(m_hFolderScreenshot){
- TCHAR szPath[1024]={0};
+ if (m_hFolderScreenshot) {
+ TCHAR szPath[1024] = { 0 };
FoldersGetCustomPathT(m_hFolderScreenshot, szPath, 1024, pszPath);
mir_free(pszPath);
pszPath = mir_tstrdup(szPath);
}
- if(!pszPath){
+ if (!pszPath) {
MessageBox(NULL, _T("Can not retrieve screenshot path."), _T("SendSS"), MB_OK | MB_ICONERROR | MB_APPLMODAL);
return 0;
}
int result = CreateDirectoryTreeT(pszPath);
- if(result){
+ if (result) {
TCHAR szError[MAX_PATH];
- mir_sntprintf(szError,MAX_PATH,TranslateT("Could not create screenshot folder (error code: %d):\n%s\nDo you have write permissions?"),result,pszPath);
+ mir_sntprintf(szError, MAX_PATH, TranslateT("Could not create screenshot folder (error code: %d):\n%s\nDo you have write permissions?"), result, pszPath);
MessageBox(NULL, szError, _T("SendSS"), MB_OK | MB_ICONERROR | MB_APPLMODAL);
mir_free(pszPath);
return 0;
@@ -88,28 +92,29 @@ TCHAR* GetCustomPath() {
return pszPath;
}
/// services
-static HANDLE m_hOpenCaptureDialog=0;
-static HANDLE m_hSendDesktop=0;
-static HANDLE m_hEditBitmap=0;
-static HANDLE m_hSend2ImageShack=0;
+static HANDLE m_hOpenCaptureDialog = 0;
+static HANDLE m_hSendDesktop = 0;
+static HANDLE m_hEditBitmap = 0;
+static HANDLE m_hSend2ImageShack = 0;
//---------------------------------------------------------------------------
// Callback function of service for contact menu and main menu
// wParam = contact handle
// lParam = 0 (or 0xFFFF to preselect window under cursor)
-INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam){
- TfrmMain* frmMain=new TfrmMain();
- if(!frmMain) {
+INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam)
+{
+ TfrmMain* frmMain = new TfrmMain();
+ if (!frmMain) {
MessageBox(NULL, TranslateT("Could not create main dialog."), TranslateT("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL);
return -1;
}
- TCHAR* pszPath=GetCustomPath();
- if(!pszPath){
+ TCHAR* pszPath = GetCustomPath();
+ if (!pszPath) {
delete frmMain;
return -1;
}
frmMain->Init(pszPath, wParam);
mir_free(pszPath);
- if(lParam==0xFFFF){
+ if (lParam == 0xFFFF) {
frmMain->SetTargetWindow(NULL);
}
frmMain->Show();
@@ -123,26 +128,27 @@ INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam){
// 2. Open the capture dialog in take screenshot only mode (it will not be sent)
// wParam = 0
// lParam = anything but 0
-INT_PTR service_SendDesktop(WPARAM wParam, LPARAM lParam) {
- TfrmMain* frmMain=new TfrmMain();
- if(!frmMain) {
+INT_PTR service_SendDesktop(WPARAM wParam, LPARAM)
+{
+ TfrmMain* frmMain = new TfrmMain();
+ if (!frmMain) {
MessageBox(NULL, TranslateT("Could not create main dialog."), TranslateT("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL);
return -1;
}
- TCHAR* pszPath=GetCustomPath();
- if(!pszPath){
+ TCHAR* pszPath = GetCustomPath();
+ if (!pszPath) {
delete frmMain;
return -1;
}
- MCONTACT hContact = (MCONTACT) wParam;
+ MCONTACT hContact = (MCONTACT)wParam;
char* pszProto = GetContactProto(hContact);
bool bChatRoom = db_get_b(hContact, pszProto, "ChatRoom", 0) != 0;
- frmMain->m_opt_chkTimed = false;
- frmMain->m_opt_tabCapture = 1;
- frmMain->m_opt_cboxDesktop = 0;
- frmMain->m_opt_chkEditor = false;
- frmMain->m_opt_cboxSendBy = bChatRoom ? SS_IMAGESHACK:SS_FILESEND;
- frmMain->Init(pszPath,hContact); // this method create the window hidden.
+ frmMain->m_opt_chkTimed = false;
+ frmMain->m_opt_tabCapture = 1;
+ frmMain->m_opt_cboxDesktop = 0;
+ frmMain->m_opt_chkEditor = false;
+ frmMain->m_opt_cboxSendBy = bChatRoom ? SS_IMAGESHACK : SS_FILESEND;
+ frmMain->Init(pszPath, hContact); // this method create the window hidden.
mir_free(pszPath);
frmMain->btnCaptureClick(); // this method will call Close()
return 0;
@@ -152,82 +158,85 @@ INT_PTR service_SendDesktop(WPARAM wParam, LPARAM lParam) {
// wParam = (SENDSSCB) callback function address to call when editing is done
// lParam = (HBITMAP) bitmap handle, a copy is made so the calling function can free this handle after the service function returns
// Returns:
-INT_PTR service_EditBitmap(WPARAM wParam, LPARAM lParam) {
-/* TfrmEdit *frmEdit=new TfrmEdit(NULL);
- if (!frmEdit)
+INT_PTR service_EditBitmap(WPARAM, LPARAM)
+{
+ /* TfrmEdit *frmEdit=new TfrmEdit(NULL);
+ if (!frmEdit)
return -1;
- Graphics::TBitmap *bitmap=new Graphics::TBitmap();
- if (!bitmap)
+ Graphics::TBitmap *bitmap=new Graphics::TBitmap();
+ if (!bitmap)
return -2;
- bitmap->Handle = (void*)lParam;
- frmEdit->InitEditor(bitmap); // a copy of the bitmap is made inside this function
- frmEdit->Show();
- delete bitmap;
-*/
+ bitmap->Handle = (void*)lParam;
+ frmEdit->InitEditor(bitmap); // a copy of the bitmap is made inside this function
+ frmEdit->Show();
+ delete bitmap;
+ */
return 0;
}
//---------------------------------------------------------------------------
// Callback function of service for sending image to imageshack.us
// wParam = (char*)filename
// lParam = (HANDLE)contact (can be null)
-INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam) {
+INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam)
+{
char* result = NULL;
CSendHost_ImageShack* cSend = new CSendHost_ImageShack(NULL, lParam, false);
cSend->m_bDeleteAfterSend = false;
cSend->SetFile((char*)wParam);
if (lParam != NULL) {
- if(cSend->Send()) delete cSend;
+ if (cSend->Send()) delete cSend;
return NULL;
}
cSend->SendSilent();
if (cSend->GetURL()) {
- result=mir_strdup(cSend->GetURL());
- }else{
- result=mir_t2a(cSend->GetErrorMsg());
+ result = mir_strdup(cSend->GetURL());
+ }
+ else {
+ result = mir_t2a(cSend->GetErrorMsg());
}
delete cSend;
return (INT_PTR)result;
}
// Functions ////////////////////////////////////////////////////////////////////////////
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
{
- g_hSendSS=hinstDLL;
+ g_hSendSS = hinstDLL;
return TRUE;
}
-static const PLUGININFOEX pluginInfo={
+static const PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
- __AUTHOR,__AUTHOREMAIL,
+ __AUTHOR, __AUTHOREMAIL,
__COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
// {ED39AF7C-BECD-404E-9499-4D04F711B9CB}
- {0xed39af7c, 0xbecd, 0x404e, {0x94, 0x99, 0x4d, 0x04, 0xf7, 0x11, 0xb9, 0xcb}}
+ { 0xed39af7c, 0xbecd, 0x404e, { 0x94, 0x99, 0x4d, 0x04, 0xf7, 0x11, 0xb9, 0xcb } }
};
-DLL_EXPORT PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+DLL_EXPORT PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return const_cast<PLUGININFOEX*>(&pluginInfo);
}
/// hooks
-static HANDLE m_hookModulesLoaded=0;
-static HANDLE m_hookSystemPreShutdown=0;
+static HANDLE m_hookModulesLoaded = 0;
+static HANDLE m_hookSystemPreShutdown = 0;
int hook_ModulesLoaded(WPARAM, LPARAM)
{
- g_myGlobals.PopupExist = ServiceExists(MS_POPUP_ADDPOPUPT);
- g_myGlobals.PopupActionsExist = ServiceExists(MS_POPUP_REGISTERACTIONS);
- g_myGlobals.PluginHTTPExist = ServiceExists(MS_HTTP_ACCEPT_CONNECTIONS);
- g_myGlobals.PluginFTPExist = ServiceExists(MS_FTPFILE_SHAREFILE);
- g_myGlobals.PluginDropboxExist = ServiceExists(MS_DROPBOX_SEND_FILE);
+ g_myGlobals.PopupExist = ServiceExists(MS_POPUP_ADDPOPUPT);
+ g_myGlobals.PopupActionsExist = ServiceExists(MS_POPUP_REGISTERACTIONS);
+ g_myGlobals.PluginHTTPExist = ServiceExists(MS_HTTP_ACCEPT_CONNECTIONS);
+ g_myGlobals.PluginFTPExist = ServiceExists(MS_FTPFILE_SHAREFILE);
+ g_myGlobals.PluginDropboxExist = ServiceExists(MS_DROPBOX_SEND_FILE);
// Netlib register
NETLIBUSER nlu = { sizeof(nlu) };
nlu.szSettingsModule = __PLUGIN_NAME;
nlu.ptszDescriptiveName = TranslateT("SendSS HTTP connections");
- nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS|NUF_TCHAR; //|NUF_NOHTTPSOPTION;
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; //|NUF_NOHTTPSOPTION;
g_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
// load my button class / or use UInfoEx
CtrlButtonLoadModule();
@@ -236,7 +245,7 @@ int hook_ModulesLoaded(WPARAM, LPARAM)
_T(PROFILE_PATH)_T("\\")_T(CURRENT_PROFILE)_T("\\Screenshots"));
return 0;
}
-int hook_SystemPreShutdown(WPARAM wParam, LPARAM lParam)
+int hook_SystemPreShutdown(WPARAM, LPARAM)
{
TfrmAbout::Unload();//crashes if done from "Unload" because of dependencies
TfrmMain::Unload();// "
@@ -247,38 +256,38 @@ int hook_SystemPreShutdown(WPARAM wParam, LPARAM lParam)
return 0;
}
-ATOM g_clsTargetHighlighter=0;
+ATOM g_clsTargetHighlighter = 0;
DLL_EXPORT int Load(void)
{
mir_getLP(&pluginInfo);
mir_getCLI();
- INT_PTR result=CallService(MS_IMG_GETINTERFACE,FI_IF_VERSION,(LPARAM)&FIP);
- if(FIP==NULL || result!=S_OK) {
+ INT_PTR result = CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&FIP);
+ if (FIP == NULL || result != S_OK) {
MessageBox(NULL, TranslateT("Image services (AdvaImg) not found.\nSendSS disabled."), TranslateT("SendSS"), MB_OK | MB_ICONERROR | MB_APPLMODAL);
return 1;
}
/// hook events
- m_hookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,hook_ModulesLoaded);
- m_hookSystemPreShutdown=HookEvent(ME_SYSTEM_PRESHUTDOWN,hook_SystemPreShutdown);
+ m_hookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, hook_ModulesLoaded);
+ m_hookSystemPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, hook_SystemPreShutdown);
/// icons
- Icon_Register(g_hSendSS,SZ_SENDSS,ICONS,sizeof(ICONS)/sizeof(IconItem),SZ_SENDSS);
- Icon_Register(g_hSendSS,SZ_SENDSS "/" LPGEN("Buttons"),ICONS_BTN,sizeof(ICONS_BTN)/sizeof(IconItem),SZ_SENDSS);
+ Icon_Register(g_hSendSS, SZ_SENDSS, ICONS, sizeof(ICONS) / sizeof(IconItem), SZ_SENDSS);
+ Icon_Register(g_hSendSS, SZ_SENDSS "/" LPGEN("Buttons"), ICONS_BTN, sizeof(ICONS_BTN) / sizeof(IconItem), SZ_SENDSS);
/// services
- #define srv_reg(name) do{\
+#define srv_reg(name) do{\
m_h##name=CreateServiceFunction(SZ_SENDSS "/" #name, service_##name);\
if(!m_h##name) MessageBoxA(NULL,Translate("Could not register Miranda service."),SZ_SENDSS "/" #name,MB_OK|MB_ICONERROR|MB_APPLMODAL);\
- }while(0)
+ }while(0)
srv_reg(OpenCaptureDialog);
srv_reg(SendDesktop);
srv_reg(EditBitmap);
srv_reg(Send2ImageShack);
-
+
// menu items
CMenuItem mi;
mi.flags = CMIF_TCHAR;
mi.hIcolibItem = GetIconHandle(ICO_MAINXS);
-
+
mi.name.t = LPGENT("Take a screenshot");
mi.pszService = MS_SENDSS_OPENDIALOG;
mi.position = 1000001;
@@ -295,19 +304,19 @@ DLL_EXPORT int Load(void)
Menu_AddContactMenuItem(&mi);
/// hotkey's
- HOTKEYDESC hkd={sizeof(hkd)};
- hkd.pszName="Open SendSS+";
- hkd.ptszDescription=LPGENT("Open SendSS+");
- hkd.ptszSection=_T("SendSS+");
- hkd.pszService=MS_SENDSS_OPENDIALOG;
+ HOTKEYDESC hkd = { sizeof(hkd) };
+ hkd.pszName = "Open SendSS+";
+ hkd.ptszDescription = LPGENT("Open SendSS+");
+ hkd.ptszSection = _T("SendSS+");
+ hkd.pszService = MS_SENDSS_OPENDIALOG;
//hkd.DefHotKey=HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL;
- hkd.lParam=0xFFFF;
+ hkd.lParam = 0xFFFF;
hkd.dwFlags = HKD_TCHAR;
Hotkey_Register(&hkd);
/// register highlighter window class
- HBRUSH brush=CreateSolidBrush(0x0000FF00);//owned by class
- WNDCLASS wndclass={CS_HREDRAW|CS_VREDRAW,DefWindowProc,0,0,g_hSendSS,NULL,NULL,brush,NULL,L"SendSSHighlighter"};
- g_clsTargetHighlighter=RegisterClass(&wndclass);
+ HBRUSH brush = CreateSolidBrush(0x0000FF00);//owned by class
+ WNDCLASS wndclass = { CS_HREDRAW | CS_VREDRAW, DefWindowProc, 0, 0, g_hSendSS, NULL, NULL, brush, NULL, L"SendSSHighlighter" };
+ g_clsTargetHighlighter = RegisterClass(&wndclass);
return 0;
}
/*---------------------------------------------------------------------------
@@ -316,15 +325,15 @@ DLL_EXPORT int Load(void)
*/
DLL_EXPORT int Unload(void)
{//as "ghazan" says, it's useless to unregister services or unhook events, let's still do it for now :P
- CallService(MS_HOTKEY_UNREGISTER,0,(LPARAM)"Open SendSS+");
+ CallService(MS_HOTKEY_UNREGISTER, 0, (LPARAM)"Open SendSS+");
/// deregister services
- #define srv_dereg(name) do{ if(m_h##name) DestroyServiceFunction(m_h##name),m_h##name=0; }while(0)
+#define srv_dereg(name) do{ if(m_h##name) DestroyServiceFunction(m_h##name),m_h##name=0; }while(0)
srv_dereg(OpenCaptureDialog);
srv_dereg(SendDesktop);
srv_dereg(EditBitmap);
srv_dereg(Send2ImageShack);
- if(m_hookModulesLoaded) UnhookEvent(m_hookModulesLoaded),m_hookModulesLoaded=0;
- if(m_hookSystemPreShutdown) UnhookEvent(m_hookSystemPreShutdown),m_hookSystemPreShutdown=0;
- if(g_clsTargetHighlighter) UnregisterClass((TCHAR*)g_clsTargetHighlighter,g_hSendSS),g_clsTargetHighlighter=0;
+ if (m_hookModulesLoaded) UnhookEvent(m_hookModulesLoaded), m_hookModulesLoaded = 0;
+ if (m_hookSystemPreShutdown) UnhookEvent(m_hookSystemPreShutdown), m_hookSystemPreShutdown = 0;
+ if (g_clsTargetHighlighter) UnregisterClass((TCHAR*)g_clsTargetHighlighter, g_hSendSS), g_clsTargetHighlighter = 0;
return 0;
}