Example #1
0
int InitSkinHotKeys(void)
{
	CreateServiceFunction("CLIST/HK/CloseMiranda",hkCloseMiranda);
	CreateServiceFunction("CLIST/HK/RestoreStatus",hkRestoreStatus);

	HOTKEYDESC shk = {0};
	shk.cbSize = sizeof(shk);
	shk.dwFlags = HKD_TCHAR;

	shk.ptszDescription = LPGENT("Close Miranda");
	shk.pszName = "CloseMiranda";
	shk.ptszSection = LPGENT("Main");
	shk.pszService = "CLIST/HK/CloseMiranda";
	Hotkey_Register(&shk);

	shk.ptszDescription = LPGENT("Restore last status");
	shk.pszName = "RestoreLastStatus";
	shk.ptszSection = LPGENT("Status");
	shk.pszService = "CLIST/HK/RestoreStatus";
	Hotkey_Register(&shk);

	shk.ptszDescription = LPGENT("Show/Hide Offline Users");
	shk.pszName = "ShowHideOfflineUsers";
	shk.ptszSection = LPGENT("Main");
	shk.pszService = MS_CLIST_TOGGLEHIDEOFFLINE;
	Hotkey_Register(&shk);


	return 0;
}
Example #2
0
/**
 * Hotkeys initialiation
 */
void FacebookProto::InitHotkeys()
{
	char text[200];
	strcpy(text, m_szModuleName);
	char* tDest = text + strlen(text);

	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszName = text;
	hkd.pszService = text;
	hkd.ptszSection = m_tszUserName;
	hkd.dwFlags = HKD_TCHAR;

	strcpy(tDest, "/VisitProfile");
	hkd.ptszDescription = LPGENT("Visit profile");
	Hotkey_Register(&hkd);

	strcpy(tDest, "/VisitNotifications");
	hkd.ptszDescription = LPGENT("Visit notifications");
	Hotkey_Register(&hkd);

	strcpy(tDest, "/Mind");
	hkd.ptszDescription = LPGENT("Show 'Share status' window");
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT | HOTKEYF_EXT, 'F');
	Hotkey_Register(&hkd);
}
Example #3
0
//register Hotkey
void LoadHotkey()
{
	HOTKEYDESC hk = { sizeof(hk) };
	hk.dwFlags = HKD_TCHAR;
	hk.pszName = "Toggle Popups";
	hk.ptszDescription = LPGENT("Toggle Popups");
	hk.ptszSection = LPGENT(MODULNAME_PLU);
	hk.pszService = MENUCOMMAND_SVC;
	Hotkey_Register(&hk);

	// 'Popup History' Hotkey
	hk.pszName = "Popup History";
	hk.ptszDescription = LPGENT("Popup History");
	hk.pszService = MENUCOMMAND_HISTORY;
	Hotkey_Register(&hk);
}
Example #4
0
void InitHotkeys()
{
	HOTKEYDESC hk = {0};
	hk.cbSize = sizeof(hk);
	hk.pszDescription = LPGEN("Show FTPFile manager");
	hk.pszName = "FTP_ShowManager";
	hk.pszSection = MODULE;
	hk.pszService = MS_FTPFILE_SHOWMANAGER;
	Hotkey_Register(&hk);
}
Example #5
0
int ModulesLoaded(WPARAM wParam,LPARAM lParam)
{
	// Register menu item
	CLISTMENUITEM mi = { sizeof(mi) };
	mi.position = 1900000001;
	mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT));
	mi.pszPopupName = "Database";
	mi.pszName = modFullname;
	mi.pszService = "DBEditorpp/MenuCommand";
	Menu_AddMainMenuItem(&mi);

	ZeroMemory(&mi, sizeof(mi));
	mi.cbSize = sizeof(mi);
	mi.position = 1900000001;
	mi.flags = db_get_b(NULL, modname, "UserMenuItem", 0) ? 0 : CMIF_HIDDEN;
	mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGUSER));
	mi.pszName = LPGEN("Open user tree in DBE++");
	mi.pszService = "DBEditorpp/MenuCommand";
	hUserMenu = Menu_AddContactMenuItem(&mi);

	// Register hotkeys
	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszName = "hk_dbepp_open";
	hkd.pszService = "DBEditorpp/MenuCommand";
	hkd.ptszDescription = LPGEN("Open Database Editor");
	hkd.ptszSection = modFullname;
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_EXT, 'D');
	Hotkey_Register(&hkd);

	// icons
	TCHAR szModuleFileName[MAX_PATH];
	if (GetModuleFileName(hInst, szModuleFileName, MAX_PATH))
		addIcons(szModuleFileName);

	UnhookEvent(hModulesLoadedHook);

	usePopups = db_get_b(NULL, modname, "UsePopUps", 0);

	// Load the name order
	for (int i = 0; i < NAMEORDERCOUNT; i++)
		nameOrder[i] = i;

	DBVARIANT dbv;
	if (!db_get(NULL, "Contact", "NameOrder", &dbv)) {
		CopyMemory(nameOrder, dbv.pbVal, dbv.cpbVal);
		db_free(&dbv);
	}

	HookEvent(ME_TTB_MODULELOADED, OnTTBLoaded);

	if (bServiceMode)
		CallService("DBEditorpp/MenuCommand", 0, 0);

	return 0;
}
Example #6
0
void RegisterCoreHotKeys (void)
{
	HOTKEYDESC hotkey = {0};
	hotkey.cbSize = sizeof(HOTKEYDESC);
	hotkey.pszName = "Hide/Show Miranda";
	hotkey.pszDescription = LPGEN("Hide/Show Miranda");
	hotkey.pszSection = "BossKey";
	hotkey.pszService = MS_BOSSKEY_HIDE;
	hotkey.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F12);

	Hotkey_Register(&hotkey);
}
Example #7
0
void CJabberProto::GlobalMenuInit()
{
    //////////////////////////////////////////////////////////////////////////////////////
    // Account chooser menu

    CMenuItem mi;
    mi.flags = CMIF_UNMOVABLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
    mi.position = iChooserMenuPos++;
    mi.name.t = m_tszUserName;
    m_hChooseMenuItem = Menu_AddItem(hChooserMenu, &mi, this);

    //////////////////////////////////////////////////////////////////////////////////////
    // Hotkeys

    char text[200];
    strncpy(text, m_szModuleName, sizeof(text) - 1);
    char* tDest = text + mir_strlen(text);

    HOTKEYDESC hkd = { sizeof(hkd) };
    hkd.pszName = text;
    hkd.pszService = text;
    hkd.ptszSection = m_tszUserName;
    hkd.dwFlags = HKD_TCHAR;

    mir_strcpy(tDest, "/Groupchat");
    hkd.ptszDescription = LPGENT("Join conference");
    Hotkey_Register(&hkd);

    mir_strcpy(tDest, "/Bookmarks");
    hkd.ptszDescription = LPGENT("Open bookmarks");
    Hotkey_Register(&hkd);

    mir_strcpy(tDest, "/PrivacyLists");
    hkd.ptszDescription = LPGENT("Privacy lists");
    Hotkey_Register(&hkd);

    mir_strcpy(tDest, "/ServiceDiscovery");
    hkd.ptszDescription = LPGENT("Service discovery");
    Hotkey_Register(&hkd);
}
Example #8
0
void AddHotkey()
{
	HOTKEYDESC hkd = {0};
	hkd.cbSize = sizeof(hkd);
	hkd.dwFlags = HKD_TCHAR;
	hkd.pszName = "AutoShutdown_Toggle";
	hkd.ptszDescription = LPGENT("Toggle Automatic Shutdown");
	hkd.ptszSection = LPGENT("Main");
	hkd.pszService = "AutoShutdown/MenuCommand";
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, 'T') | HKF_MIRANDA_LOCAL;
	hkd.lParam = FALSE;
	Hotkey_Register(&hkd);
}
Example #9
0
int ModulesLoaded(WPARAM, LPARAM)
{
	IcoLibRegister();

	// Register menu item
	CMenuItem mi;
	mi.root = Menu_CreateRoot(MO_MAIN, LPGENT("Database"), 1900000001);

	SET_UID(mi, 0xe298849c, 0x1a8c, 0x4fc7, 0xa0, 0xf4, 0x78, 0x18, 0xf, 0xe2, 0xf7, 0xc9);
	mi.position = 1900000001;
	mi.hIcolibItem = GetIcoLibHandle(ICO_DBE_BUTT);
	mi.name.a = modFullname;
	mi.pszService = "DBEditorpp/MenuCommand";
	Menu_AddMainMenuItem(&mi);

	SET_UID(mi, 0x2fed8613, 0xac43, 0x4148, 0xbd, 0x5c, 0x44, 0x88, 0xaf, 0x68, 0x69, 0x10);
	mi.root = NULL;
	mi.hIcolibItem = GetIcoLibHandle(ICO_REGUSER);
	mi.name.a = LPGEN("Open user tree in DBE++");
	mi.pszService = "DBEditorpp/MenuCommand";
	hUserMenu = Menu_AddContactMenuItem(&mi);

	// Register hotkeys
	_A2T text(modFullname);
	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.dwFlags = HKD_TCHAR;
	hkd.pszName = "hk_dbepp_open";
	hkd.pszService = "DBEditorpp/MenuCommand";
	hkd.ptszDescription = LPGENT("Open Database Editor");
	hkd.ptszSection = text;
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_EXT, 'D');
	Hotkey_Register(&hkd);

	g_bUsePopups = db_get_b(NULL, modname, "UsePopUps", 0) != 0;

	// Load the name order
	for (int i = 0; i < NAMEORDERCOUNT; i++)
		nameOrder[i] = i;

	DBVARIANT dbv = { 0 };
	if (!db_get_s(NULL, "Contact", "NameOrder", &dbv, DBVT_BLOB)) {
		memcpy(nameOrder, dbv.pbVal, dbv.cpbVal);
		db_free(&dbv);
	}

	HookEvent(ME_TTB_MODULELOADED, OnTTBLoaded);

	if (g_bServiceMode)
		CallService("DBEditorpp/MenuCommand", 0, 0);
	return 0;
}
Example #10
0
static void LoadMenus()
{
	CMenuItem mi;

	// Remove thumb menu item
	CreateServiceFunction(MODULE "/RemoveThumb", OnContactMenu_Remove);
	SET_UID(mi,0xbab83df0, 0xe126, 0x4d9a, 0xbc, 0xc3, 0x2b, 0xea, 0x84, 0x90, 0x58, 0xc8);
	mi.position = 0xFFFFF;
	mi.flags = CMIF_TCHAR;
	mi.hIcolibItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_HIDE));
	mi.name.t = LPGENT("Remove thumb");
	mi.pszService = MODULE "/RemoveThumb";
	hMenuItemRemove = Menu_AddContactMenuItem(&mi);

	// Hide all thumbs main menu item
	CreateServiceFunction(MODULE "/MainHideAllThumbs", OnMainMenu_HideAll);
	SET_UID(mi, 0x9ce9983f, 0x782a, 0x4ec1, 0xb5, 0x9b, 0x41, 0x4e, 0x9d, 0x92, 0x8e, 0xcb);
	mi.pszService = MODULE "/MainHideAllThumbs";
	int i = (fcOpt.bHideAll) ? 0 : 1;
	mi.hIcolibItem = g_iconList[i].hIcolib;
	mi.name.t = g_iconList[i].tszDescr;
	hMainMenuItemHideAll = Menu_AddMainMenuItem(&mi);

	// Register hotkeys
	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszSection = "Floating Contacts";

	hkd.pszName = MODULE "/MainHideAllThumbs";
	hkd.pszDescription = LPGEN("Show/Hide all thumbs");
	hkd.pszService = MODULE "/MainHideAllThumbs";
	Hotkey_Register(&hkd);

	CreateServiceFunction(MODULE "/HideWhenCListShow", OnHotKey_HideWhenCListShow);
	hkd.pszName = MODULE "/HideWhenCListShow";
	hkd.pszDescription = LPGEN("Hide when contact list is shown");
	hkd.pszService = MODULE "/HideWhenCListShow";
	Hotkey_Register(&hkd);
}
Example #11
0
/**
 * Hotkeys initialiation
 */
void FacebookProto::InitHotkeys()
{
	char module[512];
	mir_snprintf(module, sizeof(module), "%s/Mind", m_szModuleName);

	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.dwFlags = HKD_TCHAR;
	hkd.ptszDescription = LPGENT("Show 'Share status' window");
	hkd.pszName = "ShowMindWnd";
	hkd.ptszSection = m_tszUserName;
	hkd.pszService = module;
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT|HOTKEYF_EXT, 'F');
	Hotkey_Register(&hkd);
}
Example #12
0
static void LoadMenus()
{
	// Remove thumb menu item
	CreateServiceFunction(MODULE "/RemoveThumb", OnContactMenu_Remove);

	CLISTMENUITEM mi = { sizeof(mi) };
	mi.position = 0xFFFFF;
	mi.flags = CMIF_TCHAR;
	mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_HIDE));
	mi.ptszName = LPGENT("Remove thumb");
	mi.pszService = MODULE "/RemoveThumb";
	hMenuItemRemove = Menu_AddContactMenuItem(&mi);

	// Hide all thumbs main menu item
	CreateServiceFunction(MODULE "/MainHideAllThumbs", OnMainMenu_HideAll );

	mi.hIcon = LoadIcon( hInst, MAKEINTRESOURCE( fcOpt.bHideAll ? IDI_SHOW : IDI_HIDE ));
	mi.ptszName = fcOpt.bHideAll ? LPGENT("Show all thumbs") : LPGENT("Hide all thumbs");
	mi.pszService = MODULE "/MainHideAllThumbs";
	Menu_AddMainMenuItem(&mi);

	// Register hotkeys
	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszSection = "Floating Contacts";

	hkd.pszName = MODULE "/MainHideAllThumbs";
	hkd.pszDescription = LPGEN("Show/Hide all thumbs");
	hkd.pszService = MODULE "/MainHideAllThumbs";
	Hotkey_Register(&hkd);

	CreateServiceFunction(MODULE "/HideWhenCListShow", OnHotKey_HideWhenCListShow );
	hkd.pszName = MODULE "/HideWhenCListShow";
	hkd.pszDescription = LPGEN("Hide when contact list is shown");
	hkd.pszService = MODULE "/HideWhenCListShow";
	Hotkey_Register(&hkd);
}
Example #13
0
extern "C" __declspec(dllexport) int Load(void)
{
	mir_getLP(&pluginInfoEx);

	CreateServiceFunction(MS_TS_SWITCHLAYOUT, ServiceSwitch);
	CreateServiceFunction(MS_TS_TRANSLITLAYOUT, ServiceTranslit);
	CreateServiceFunction(MS_TS_INVERTCASE, ServiceInvert);

	HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
	HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);

	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.dwFlags = HKD_TCHAR;
	hkd.pszName = "TranslitSwitcher/ConvertAllOrSelected";
	hkd.ptszDescription = LPGENT("Convert All / Selected");
	hkd.ptszSection = _T("TranslitSwitcher");
	hkd.pszService = MS_TS_SWITCHLAYOUT;
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL + HKCOMB_A, 'R') | HKF_MIRANDA_LOCAL;
	Hotkey_Register(&hkd);

	hkd.pszName = "TranslitSwitcher/ConvertLastOrSelected";
	hkd.ptszDescription = LPGENT("Convert Last / Selected");
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT + HKCOMB_A, 'R') | HKF_MIRANDA_LOCAL;
	hkd.lParam = true;
	Hotkey_Register(&hkd);

	hkd.pszName = "TranslitSwitcher/TranslitAllOrSelected";
	hkd.ptszDescription = LPGENT("Translit All / Selected");
	hkd.pszService = MS_TS_TRANSLITLAYOUT;
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL + HKCOMB_A, 'T') | HKF_MIRANDA_LOCAL;
	hkd.lParam = false;
	Hotkey_Register(&hkd);

	hkd.pszName = "TranslitSwitcher/TranslitLastOrSelected";
	hkd.ptszDescription = LPGENT("Translit Last / Selected");
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT + HKCOMB_A, 'T') | HKF_MIRANDA_LOCAL;
	hkd.lParam = true;
	Hotkey_Register(&hkd);

	hkd.pszName = "TranslitSwitcher/InvertCaseAllOrSelected";
	hkd.ptszDescription = LPGENT("Invert Case All / Selected");
	hkd.pszService = MS_TS_INVERTCASE;
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL + HKCOMB_A, 'Y') | HKF_MIRANDA_LOCAL;
	hkd.lParam = false;
	Hotkey_Register(&hkd);

	hkd.pszName = "TranslitSwitcher/InvertCaseLastOrSelected";
	hkd.ptszDescription = LPGENT("Invert Case Last / Selected");
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT + HKCOMB_A, 'Y') | HKF_MIRANDA_LOCAL;
	hkd.lParam = true;
	Hotkey_Register(&hkd);
	return 0;
}
Example #14
0
int ModulesLoaded(WPARAM, LPARAM)
{
	Silent = true;
	HOTKEYDESC hkd = { 0 };
	hkd.cbSize = sizeof(hkd);
	hkd.dwFlags = HKD_TCHAR;
	hkd.pszName = "Check for pack updates";
	hkd.ptszDescription = LPGENT("Check for pack updates");
	hkd.ptszSection = LPGENT("Pack Updater");
	hkd.pszService = MODNAME"/CheckUpdates";
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL;
	hkd.lParam = FALSE;
	Hotkey_Register(&hkd);

	if (AllowUpdateOnStartup())
		DoCheck(UpdateOnStartup);

	Timer = CreateWaitableTimer(NULL, FALSE, NULL);
	InitTimer();

	return 0;
}
Example #15
0
TwitterProto::TwitterProto(const char *proto_name, const TCHAR *username) :
	PROTO<TwitterProto>(proto_name, username)
{
	CreateProtoService(PS_CREATEACCMGRUI, &TwitterProto::SvcCreateAccMgrUI);
	CreateProtoService(PS_GETNAME, &TwitterProto::GetName);
	CreateProtoService(PS_GETSTATUS, &TwitterProto::GetStatus);

	CreateProtoService(PS_JOINCHAT, &TwitterProto::OnJoinChat);
	CreateProtoService(PS_LEAVECHAT, &TwitterProto::OnLeaveChat);

	CreateProtoService(PS_GETMYAVATAR, &TwitterProto::GetAvatar);
	CreateProtoService(PS_SETMYAVATAR, &TwitterProto::SetAvatar);

	HookProtoEvent(ME_OPT_INITIALISE, &TwitterProto::OnOptionsInit);
	HookProtoEvent(ME_DB_CONTACT_DELETED, &TwitterProto::OnContactDeleted);
	HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &TwitterProto::OnBuildStatusMenu);

	// Initialize hotkeys
	char text[512];
	mir_snprintf(text, "%s/Tweet", m_szModuleName);

	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszName = text;
	hkd.pszService = text;
	hkd.pszSection = m_szModuleName; // Section title; TODO: use username?
	hkd.pszDescription = "Send Tweet";
	Hotkey_Register(&hkd);

	// set Tokens and stuff

	//mirandas keys
	ConsumerKey = OAUTH_CONSUMER_KEY;
	ConsumerSecret = OAUTH_CONSUMER_SECRET;

	AuthorizeUrl = _T("https://api.twitter.com/oauth/authorize?oauth_token=%s");
}
Example #16
0
LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static POINT ptLast;
	static int iMousedown;

	if (msg == WM_TASKBARCREATED) {
		CreateSystrayIcon(FALSE);
		if (nen_options.bTraySupport)
			CreateSystrayIcon(TRUE);
		return 0;
	}

	TContainerData *p;

	switch (msg) {
	case WM_CREATE:
		for (int i=0; i < SIZEOF(_hotkeydescs); i++) {
			_hotkeydescs[i].cbSize = sizeof(HOTKEYDESC);
			Hotkey_Register(&_hotkeydescs[i]);
		}

		WM_TASKBARCREATED = RegisterWindowMessageA("TaskbarCreated");
		ShowWindow(hwndDlg, SW_HIDE);
		hSvcHotkeyProcessor = CreateServiceFunction(MS_TABMSG_HOTKEYPROCESS, HotkeyProcessor);
		SetTimer(hwndDlg, TIMERID_SENDLATER, TIMEOUT_SENDLATER, NULL);
		break;

	case WM_HOTKEY:
		{
			CLISTEVENT *cli = (CLISTEVENT *)CallService(MS_CLIST_GETEVENT, (WPARAM)INVALID_HANDLE_VALUE, 0);
			if (cli != NULL) {
				if (strncmp(cli->pszService, "SRMsg/TypingMessage", strlen(cli->pszService))) {
					CallService(cli->pszService, 0, (LPARAM)cli);
					break;
				}
			}
			if (wParam == 0xc001)
				SendMessage(hwndDlg, DM_TRAYICONNOTIFY, 101, WM_MBUTTONDOWN);
		}
		break;

	// handle the popup menus (session list, favorites, recents...
	// just draw some icons, nothing more :)
	case WM_MEASUREITEM:
		{
			LPMEASUREITEMSTRUCT lpmi = (LPMEASUREITEMSTRUCT) lParam;
			lpmi->itemHeight = 0;
			lpmi->itemWidth = 6;
		}
		return TRUE;

	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
			TWindowData *dat = 0;
			if (dis->CtlType == ODT_MENU && (dis->hwndItem == (HWND)PluginConfig.g_hMenuFavorites || dis->hwndItem == (HWND)PluginConfig.g_hMenuRecent)) {
				HICON hIcon = (HICON)dis->itemData;

				DrawMenuItem(dis, hIcon, 0);
				return TRUE;
			}
			else if (dis->CtlType == ODT_MENU) {
				HWND hWnd = M.FindWindow((MCONTACT)dis->itemID);
				DWORD idle = 0;

				if (hWnd == NULL) {
					SESSION_INFO *si = SM_FindSessionByHCONTACT((MCONTACT)dis->itemID);
					hWnd = si ? si->hWnd : 0;
				}

				if (hWnd)
					dat = (TWindowData*)GetWindowLongPtr(hWnd, GWLP_USERDATA);

				if (dis->itemData >= 0) {
					HICON hIcon;

					if (dis->itemData > 0)
						hIcon = dis->itemData & 0x10000000 ? pci->hIcons[ICON_HIGHLIGHT] : PluginConfig.g_IconMsgEvent;
					else if (dat != NULL) {
						hIcon = MY_GetContactIcon(dat);
						idle = dat->idle;
					}
					else hIcon = PluginConfig.g_iconContainer;

					DrawMenuItem(dis, hIcon, idle);
					return TRUE;
				}
			}
		}
		break;

	case DM_TRAYICONNOTIFY:
		if (wParam == 100 || wParam == 101) {
			switch (lParam) {
			case WM_LBUTTONUP:
				{
					POINT pt;
					GetCursorPos(&pt);
					if (wParam == 100)
						SetForegroundWindow(hwndDlg);
					if (GetMenuItemCount(PluginConfig.g_hMenuTrayUnread) > 0) {
						BOOL iSelection = TrackPopupMenu(PluginConfig.g_hMenuTrayUnread, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
						HandleMenuEntryFromhContact((MCONTACT)iSelection);
					}
					else TrackPopupMenu(GetSubMenu(PluginConfig.g_hMenuContext, 8), TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);

					if (wParam == 100)
						PostMessage(hwndDlg, WM_NULL, 0, 0);
				}
				break;

			case WM_MBUTTONDOWN:
				{
					if (wParam == 100)
						SetForegroundWindow(hwndDlg);

					int iCount = GetMenuItemCount(PluginConfig.g_hMenuTrayUnread);
					if (iCount > 0) {
						UINT uid = 0;
						MENUITEMINFOA mii = {0};
						mii.fMask = MIIM_DATA;
						mii.cbSize = sizeof(mii);
						int i = iCount - 1;
						do {
							GetMenuItemInfoA(PluginConfig.g_hMenuTrayUnread, i, TRUE, &mii);
							if (mii.dwItemData > 0) {
								uid = GetMenuItemID(PluginConfig.g_hMenuTrayUnread, i);
								HandleMenuEntryFromhContact((MCONTACT)uid);
								break;
							}
						}
							while (--i >= 0);

						if (uid == 0 && pLastActiveContainer != NULL) {                // no session found, restore last active container
							if (IsIconic(pLastActiveContainer->hwnd) || !IsWindowVisible(pLastActiveContainer->hwnd)) {
								SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
								SetForegroundWindow(pLastActiveContainer->hwnd);
								SetFocus(GetDlgItem(pLastActiveContainer->hwndActive, IDC_MESSAGE));
							}
							else if (GetForegroundWindow() != pLastActiveContainer->hwnd) {
								SetForegroundWindow(pLastActiveContainer->hwnd);
								SetFocus(GetDlgItem(pLastActiveContainer->hwndActive, IDC_MESSAGE));
							}
							else {
								if (PluginConfig.m_HideOnClose)
									ShowWindow(pLastActiveContainer->hwnd, SW_HIDE);
								else
									SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
							}
						}
					}
					if (wParam == 100)
						PostMessage(hwndDlg, WM_NULL, 0, 0);
				}
				break;

			case WM_RBUTTONUP:
				{
					HMENU submenu = PluginConfig.g_hMenuTrayContext;
					POINT pt;

					if (wParam == 100)
						SetForegroundWindow(hwndDlg);
					GetCursorPos(&pt);
					CheckMenuItem(submenu, ID_TRAYCONTEXT_DISABLEALLPOPUPS, MF_BYCOMMAND | (nen_options.iDisable ? MF_CHECKED : MF_UNCHECKED));
					CheckMenuItem(submenu, ID_TRAYCONTEXT_DON40223, MF_BYCOMMAND | (nen_options.iNoSounds ? MF_CHECKED : MF_UNCHECKED));
					CheckMenuItem(submenu, ID_TRAYCONTEXT_DON, MF_BYCOMMAND | (nen_options.iNoAutoPopup ? MF_CHECKED : MF_UNCHECKED));
					EnableMenuItem(submenu, ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS, MF_BYCOMMAND | (nen_options.bTraySupport) ? MF_ENABLED : MF_GRAYED);
					CheckMenuItem(submenu, ID_TRAYCONTEXT_SHOWTHETRAYICON, MF_BYCOMMAND | (nen_options.bTraySupport ? MF_CHECKED : MF_UNCHECKED));
					BOOL iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
					if (iSelection) {
						MENUITEMINFO mii = {0};

						mii.cbSize = sizeof(mii);
						mii.fMask = MIIM_DATA | MIIM_ID;
						GetMenuItemInfo(submenu, (UINT_PTR)iSelection, FALSE, &mii);
						if (mii.dwItemData != 0)  // this must be an itm of the fav or recent menu
							HandleMenuEntryFromhContact((MCONTACT)iSelection);
						else {
							switch (iSelection) {
							case ID_TRAYCONTEXT_SHOWTHETRAYICON:
								nen_options.bTraySupport = !nen_options.bTraySupport;
								CreateSystrayIcon(nen_options.bTraySupport ? TRUE : FALSE);
								break;
							case ID_TRAYCONTEXT_DISABLEALLPOPUPS:
								nen_options.iDisable ^= 1;
								break;
							case ID_TRAYCONTEXT_DON40223:
								nen_options.iNoSounds ^= 1;
								break;
							case ID_TRAYCONTEXT_DON:
								nen_options.iNoAutoPopup ^= 1;
								break;
							case ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS:
								for (p = pFirstContainer; p; p = p->pNext)
									ShowWindow(p->hwnd, SW_HIDE);
								break;
							case ID_TRAYCONTEXT_RESTOREALLMESSAGECONTAINERS:
								for (p = pFirstContainer; p; p = p->pNext)
									ShowWindow(p->hwnd, SW_SHOW);
								break;
							case ID_TRAYCONTEXT_BE:
								nen_options.iDisable = 1;
								nen_options.iNoSounds = 1;
								nen_options.iNoAutoPopup = 1;

								for (p = pFirstContainer; p; p = p->pNext)
									SendMessage(p->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 1);
								break;
							}
						}
					}
					if (wParam == 100)
						PostMessage(hwndDlg, WM_NULL, 0, 0);
					break;
				}
			}
		}
		break;

	// handle an event from the popup module (mostly window activation). Since popups may run in different threads, the message
	// is posted to our invisible hotkey handler which does always run within the main thread.
	// wParam is the hContact
	// lParam the event handle
	case DM_HANDLECLISTEVENT:
		// if lParam == NULL, don't consider clist events, just open the message tab
		if (lParam == 0)
			HandleMenuEntryFromhContact(wParam);
		else {
			CLISTEVENT *cle = (CLISTEVENT *)CallService(MS_CLIST_GETEVENT, wParam, 0);
			if (cle) {
				if (ServiceExists(cle->pszService)) {
					CallService(cle->pszService, 0, (LPARAM)cle);
					CallService(MS_CLIST_REMOVEEVENT, (WPARAM)cle->hContact, (LPARAM)cle->hDbEvent);
				}
			}
			// still, we got that message posted.. the event may be waiting in tabSRMMs tray...
			else HandleMenuEntryFromhContact(wParam);
		}
		break;

	case DM_DOCREATETAB:
		{
			HWND hWnd = M.FindWindow(lParam);
			if (hWnd && IsWindow(hWnd)) {
				TContainerData *pContainer = 0;
				SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
				if (pContainer) {
					int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, IDC_MSGTABS));
					if (iTabs == 1)
						SendMessage(pContainer->hwnd, WM_CLOSE, 0, 1);
					else
						SendMessage(hWnd, WM_CLOSE, 0, 1);

					CreateNewTabForContact((TContainerData*)wParam, lParam, 0, NULL, TRUE, TRUE, FALSE, 0);
				}
			}
		}
		break;

	case DM_DOCREATETAB_CHAT:
		{
			SESSION_INFO *si = SM_FindSessionByHWND((HWND)lParam);
			if (si && IsWindow(si->hWnd)) {
				TContainerData *pContainer = 0;
				SendMessage(si->hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
				if (pContainer) {
					int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, 1159));
					if (iTabs == 1)
						SendMessage(pContainer->hwnd, WM_CLOSE, 0, 1);
					else
						SendMessage(si->hWnd, WM_CLOSE, 0, 1);

					si->hWnd = CreateNewRoom((TContainerData*)wParam, si, TRUE, 0, 0);
				}
			}
		}
		break;

	case DM_SENDMESSAGECOMMANDW:
		SendMessageCommand_W(wParam, lParam);
		if (lParam)
			mir_free((void*)lParam);
		return 0;

	case DM_SENDMESSAGECOMMAND:
		SendMessageCommand(wParam, lParam);
		if (lParam)
			mir_free((void*)lParam);
		return 0;

	// sent from the popup to "dismiss" the event. we should do this in the main thread
	case DM_REMOVECLISTEVENT:
		CallService(MS_CLIST_REMOVEEVENT, wParam, lParam);
		db_event_markRead(wParam, (HANDLE)lParam);
		return 0;

	case DM_SETLOCALE:
		{
			HKL hkl = (HKL)lParam;
			MCONTACT hContact = wParam;

			HWND	hWnd = M.FindWindow(hContact);
			if (hWnd) {
				TWindowData *dat = (TWindowData*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
				if (dat) {
					if (hkl) {
						dat->hkl = hkl;
						PostMessage(dat->hwnd, DM_SETLOCALE, 0, 0);
					}

					DBVARIANT  dbv;
					if (0 == db_get_ts(hContact, SRMSGMOD_T, "locale", &dbv)) {
						GetLocaleID(dat, dbv.ptszVal);
						db_free(&dbv);
						UpdateReadChars(dat);
					}
				}
			}
		}
		return 0;

	// react to changes in the desktop composition state
	// (enable/disable DWM, change to a non-aero visual style
	// or classic Windows theme
	case WM_DWMCOMPOSITIONCHANGED:
		{
			bool fNewAero = M.getAeroState();					// refresh dwm state
			SendMessage(hwndDlg, WM_THEMECHANGED, 0, 0);

			for (p = pFirstContainer; p; p = p->pNext) {
				if (fNewAero)
					SetAeroMargins(p);
				else {
					MARGINS m = {0};
					if (M.m_pfnDwmExtendFrameIntoClientArea)
						M.m_pfnDwmExtendFrameIntoClientArea(p->hwnd, &m);
				}
				if (p->SideBar->isActive())
					RedrawWindow(GetDlgItem(p->hwnd, 5000), NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);			// the container for the sidebar buttons
				RedrawWindow(p->hwnd, NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
			}
		}
		M.BroadcastMessage(WM_DWMCOMPOSITIONCHANGED, 0, 0);
		break;

	// this message is fired when the user changes desktop color
	// settings (Desktop->personalize)
	// the handler reconfigures the aero-related skin images for
	// tabs and buttons to match the new desktop color theme.
	case WM_DWMCOLORIZATIONCOLORCHANGED:
		M.getAeroState();
		Skin->setupAeroSkins();
		CSkin::initAeroEffect();
		break;

	// user has changed the visual style or switched to/from
	// classic Windows theme
	case WM_THEMECHANGED:
		M.getAeroState();
		Skin->setupTabCloseBitmap();
		CSkin::initAeroEffect();
		PluginConfig.m_ncm.cbSize = sizeof(NONCLIENTMETRICS);
		SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &PluginConfig.m_ncm, 0);
		FreeTabConfig();
		ReloadTabConfig();

		for (p = pFirstContainer; p; p = p->pNext) {
			SendMessage(GetDlgItem(p->hwnd, IDC_MSGTABS), EM_THEMECHANGED, 0, 0);
			BroadCastContainer(p, EM_THEMECHANGED, 0, 0);
		}
		break;

	case DM_SPLITSENDACK:
		{
			SendJob *job = sendQueue->getJobByIndex((int)wParam);

			ACKDATA ack = {0};
			ack.hContact = job->hOwner;
			ack.hProcess = job->hSendId;
			ack.type = ACKTYPE_MESSAGE;
			ack.result = ACKRESULT_SUCCESS;

			if (job->hOwner && job->iAcksNeeded && job->hOwner && job->iStatus == SendQueue::SQ_INPROGRESS) {
				if (IsWindow(job->hwndOwner))
					::SendMessage(job->hwndOwner, HM_EVENTSENT, (WPARAM)MAKELONG(wParam, 0), (LPARAM)&ack);
				else
					sendQueue->ackMessage(0, (WPARAM)MAKELONG(wParam, 0), (LPARAM)&ack);
			}
		}
		return 0;

	case DM_LOGSTATUSCHANGE:
		CGlobals::logStatusChange(wParam, reinterpret_cast<CContactCache *>(lParam));
		return 0;

	case DM_MUCFLASHWORKER:
		{
			FLASH_PARAMS *p = reinterpret_cast<FLASH_PARAMS*>(lParam);
			if (1 == wParam) {
				CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)p->hContact, 1);
				p->bActiveTab = TRUE;
				p->bInactive = FALSE;
				p->bMustAutoswitch = p->bMustFlash = FALSE;
			}

			if (2 == wParam) {
				p->bActiveTab = TRUE;
				p->bInactive = FALSE;
				p->bMustAutoswitch = p->bMustFlash = FALSE;
				SendMessage(p->hWnd, DM_ACTIVATEME, 0, 0);
			}
			DoFlashAndSoundWorker(p);
		}
		return 0;

	case WM_POWERBROADCAST:
	case WM_DISPLAYCHANGE:
		for (p = pFirstContainer; p; p = p->pNext)
			if (CSkin::m_skinEnabled) {             // invalidate cached background DCs for skinned containers
				p->oldDCSize.cx = p->oldDCSize.cy = 0;
				SelectObject(p->cachedDC, p->oldHBM);
				DeleteObject(p->cachedHBM);
				DeleteDC(p->cachedDC);
				p->cachedDC = 0;
				RedrawWindow(p->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME);
			}
			break;

	case WM_ACTIVATE:
		if (LOWORD(wParam) != WA_ACTIVE)
			SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
		return 0;

	case WM_CLOSE:
		return 0;

	case WM_TIMER:
		if (wParam == TIMERID_SENDLATER) {
			// send heartbeat to each container, they use this to update
			// dynamic content (i.e. local time in the info panel).
			for (p = pFirstContainer; p; p = p->pNext)
				SendMessage(p->hwnd, WM_TIMER, TIMERID_HEARTBEAT, 0);

			// process send later contacts and jobs, if enough time has elapsed
			if (sendLater->isAvail() && !sendLater->isInteractive() && (time(0) - sendLater->lastProcessed()) > CSendLater::SENDLATER_PROCESS_INTERVAL) {
				sendLater->setLastProcessed(time(0));

				// check the list of contacts that may have new send later jobs
				// (added on user's request)
				sendLater->processContacts();

				// start processing the job list
				if (!sendLater->isJobListEmpty()) {
					KillTimer(hwndDlg, wParam);
					sendLater->startJobListProcess();
					SetTimer(hwndDlg, TIMERID_SENDLATER_TICK, TIMEOUT_SENDLATER_TICK, 0);
				}
			}
		}

		// process one entry per tick (default: 200ms)
		// TODO better timings, possibly slow down when many jobs are in the
		// queue.
		else if (wParam == TIMERID_SENDLATER_TICK) {
			if ( !sendLater->haveJobs()) {
				KillTimer(hwndDlg, wParam);
				SetTimer(hwndDlg, TIMERID_SENDLATER, TIMEOUT_SENDLATER, 0);
				sendLater->qMgrUpdate(true);
			}
			else sendLater->processCurrentJob();
		}
		break;

	case WM_DESTROY:
		KillTimer(hwndDlg, TIMERID_SENDLATER_TICK);
		KillTimer(hwndDlg, TIMERID_SENDLATER);
		DestroyServiceFunction(hSvcHotkeyProcessor);
		break;
	}
	return DefWindowProc(hwndDlg, msg, wParam, lParam);
}
Example #17
0
/*
static INT_PTR hkCloseMiranda(WPARAM wParam, LPARAM lParam)
{
	CallService("CloseAction", 0, 0);
	return 0;
}

INT_PTR hkRestoreStatus(WPARAM wParam, LPARAM lParam)
{
	int nStatus = db_get_w(NULL, "CList", "Status", ID_STATUS_OFFLINE);
	CallService(MS_CLIST_SETSTATUSMODE, nStatus, 0);
	return 0;
}

static INT_PTR hkAllOffline(WPARAM, LPARAM)
{
	CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_OFFLINE, 0);
	return 0;
}
*/
int InitClistHotKeys(void)
{
	CreateServiceFunction("CLIST/HK/SHOWHIDE", hkHideShow);
	CreateServiceFunction("CLIST/HK/Opts", hkOpts);
	CreateServiceFunction("CLIST/HK/Read", hkRead);

	HOTKEYDESC shk = { sizeof(shk) };
	shk.dwFlags = HKD_TCHAR;
	shk.ptszDescription = LPGENT("Show/Hide contact list");
	shk.pszName = "ShowHide";
	shk.ptszSection = _T("Main");
	shk.pszService = "CLIST/HK/SHOWHIDE";
	shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'A');
	Hotkey_Register(&shk);

	shk.ptszDescription = LPGENT("Read message");
	shk.pszName = "ReadMessage";
	shk.ptszSection = _T("Main");
	shk.pszService = "CLIST/HK/Read";
	shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'I');
	Hotkey_Register(&shk);
/*
	shk.pszDescription = "Search in site";
	shk.pszName = "SearchInWeb";
	shk.pszSection = "Main";
	shk.pszService = "CLIST/HK/Search";
	shk.DefHotKey = 846;
	Hotkey_Register(&shk);
*/
	shk.ptszDescription = LPGENT("Open Options page");
	shk.pszName = "ShowOptions";
	shk.ptszSection = _T("Main");
	shk.pszService = "CLIST/HK/Opts";
	shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'O') | HKF_MIRANDA_LOCAL;
	Hotkey_Register(&shk);

	shk.ptszDescription = LPGENT("Open logging options");
	shk.pszName = "ShowLogOptions";
	shk.ptszSection = _T("Main");
	shk.pszService = "Netlib/Log/Win";
	shk.DefHotKey = 0;
	Hotkey_Register(&shk);

	shk.ptszDescription = LPGENT("Open 'Find user' dialog");
	shk.pszName = "FindUsers";
	shk.ptszSection = _T("Main");
	shk.pszService = "FindAdd/FindAddCommand";
	shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'F') | HKF_MIRANDA_LOCAL;
	Hotkey_Register(&shk);

/*
	shk.pszDescription = "Close Miranda";
	shk.pszName = "CloseMiranda";
	shk.pszSection = "Main";
	shk.pszService = "CLIST/HK/CloseMiranda";
	shk.DefHotKey = 0;
	Hotkey_Register(&shk);

	shk.pszDescription = "Restore last status";
	shk.pszName = "RestoreLastStatus";
	shk.pszSection = "Status";
	shk.pszService = "CLIST/HK/RestoreStatus";
	shk.DefHotKey = 0;
	Hotkey_Register(&shk);

	shk.pszDescription = "Set All Offline";
	shk.pszName = "AllOffline";
	shk.pszSection = "Status";
	shk.pszService = "CLIST/HK/AllOffline";
	shk.DefHotKey = 0;
	Hotkey_Register(&shk);
*/
	return 0;
}
Example #18
0
static int PluginInit(WPARAM, LPARAM)
{
	HookEvent(ME_MSG_WINDOWEVENT, GetContactHandle);
	HookEvent(ME_OPT_INITIALISE, OptionsInit);
	HookEvent(ME_TTB_MODULELOADED, CreateButtons);

	// Hotkeys
	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszSection = LPGEN("Sessions");
	hkd.pszName = "OpenSessionsManager";
	hkd.pszDescription = LPGEN("Open Sessions Manager");
	hkd.pszService = MS_SESSIONS_OPENMANAGER;
	Hotkey_Register(&hkd);

	hkd.pszName = "RestoreLastSession";
	hkd.pszDescription = LPGEN("Restore last Session");
	hkd.pszService = MS_SESSIONS_RESTORELASTSESSION;
	Hotkey_Register(&hkd);

	hkd.pszName = "SaveSession";
	hkd.pszDescription = LPGEN("Save Session");
	hkd.pszService = MS_SESSIONS_SAVEUSERSESSION;
	Hotkey_Register(&hkd);

	hkd.pszName = "CloseSession";
	hkd.pszDescription = LPGEN("Close Session");
	hkd.pszService = MS_SESSIONS_CLOSESESSION;
	Hotkey_Register(&hkd);

	// Main menu
	CMenuItem mi;
	mi.position = 1000000000;
	mi.root = Menu_CreateRoot(MO_MAIN, LPGENT("Sessions Manager"), 1000000000);
	Menu_ConfigureItem(mi.root, MCI_OPT_UID, "D77B9AB4-AF7E-43DB-A487-BD581704D635");

	SET_UID(mi, 0xd35302fa, 0x8326, 0x4323, 0xa3, 0xe5, 0xb4, 0x41, 0xff, 0xfb, 0xaa, 0x2d);
	mi.name.a = LPGEN("Save session...");
	mi.hIcolibItem = iconList[4].hIcolib;
	mi.pszService = MS_SESSIONS_SAVEUSERSESSION;
	hmSaveCurrentSession = Menu_AddMainMenuItem(&mi);

	SET_UID(mi, 0x8de4d8b1, 0x9a62, 0x4f4e, 0xb0, 0x3d, 0x99, 0x7, 0x80, 0xe8, 0x93, 0xc2);
	mi.name.a = LPGEN("Load session...");
	mi.pszService = MS_SESSIONS_OPENMANAGER;
	mi.hIcolibItem = iconList[3].hIcolib;
	Menu_AddMainMenuItem(&mi);

	SET_UID(mi, 0x73ea91d6, 0xb7e5, 0x4f67, 0x96, 0x96, 0xa, 0x24, 0x21, 0x48, 0x6f, 0x15);
	mi.name.a = LPGEN("Close session");
	mi.pszService = MS_SESSIONS_CLOSESESSION;
	mi.hIcolibItem = 0;
	Menu_AddMainMenuItem(&mi);

	SET_UID(mi, 0xe2c4e4ba, 0x5d08, 0x441b, 0xb5, 0x93, 0xc4, 0xe7, 0x9a, 0xfb, 0xa4, 0x6c);
	mi.name.a = LPGEN("Load last session");
	mi.pszService = MS_SESSIONS_RESTORELASTSESSION;
	mi.hIcolibItem = iconList[5].hIcolib;
	mi.position = 10100000;
	Menu_AddMainMenuItem(&mi);
	return 0;
}
Example #19
0
static int PluginInit(WPARAM wparam,LPARAM lparam)
{
	int startup=0;

	HookEvent(ME_MSG_WINDOWEVENT, GetContactHandle);
	HookEvent(ME_OPT_INITIALISE,  OptionsInit);
	HookEvent(ME_TTB_MODULELOADED, CreateButtons);

	startup=db_get_b(NULL, MODNAME, "StartupMode", 3);

	if (startup == 1||(startup == 3&&isLastTRUE == TRUE))
	{
		StartUp=TRUE;
		g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc);
	}
	else if (startup == 2&&isLastTRUE == TRUE)
	{
		g_hghostw=TRUE;
		g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc);
	}

	// Hotkeys
	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.dwFlags = HKD_TCHAR;
	hkd.ptszSection = LPGENT("Sessions");
	hkd.pszName = "OpenSessionsManager";
	hkd.ptszDescription = LPGENT("Open Sessions Manager");
	hkd.pszService = MS_SESSIONS_OPENMANAGER;
	Hotkey_Register(&hkd);

	hkd.pszName = "RestoreLastSession";
	hkd.ptszDescription = LPGENT("Restore last Session");
	hkd.pszService = MS_SESSIONS_RESTORELASTSESSION;
	Hotkey_Register(&hkd);

	hkd.pszName = "SaveSession";
	hkd.ptszDescription = LPGENT("Save Session");
	hkd.pszService = MS_SESSIONS_SAVEUSERSESSION;
	Hotkey_Register(&hkd);

	hkd.pszName = "CloseSession";
	hkd.ptszDescription = LPGENT("Close Session");
	hkd.pszService = MS_SESSIONS_CLOSESESSION;
	Hotkey_Register(&hkd);

	// Icons
	Icon_Register(hinstance, MODNAME, iconList, SIZEOF(iconList));

	// Main menu
	CLISTMENUITEM cl = { sizeof(cl) };
	cl.position = 1000000000;
	cl.flags = CMIM_ALL | CMIF_TCHAR;

	cl.ptszName = LPGENT("Save session...");
	cl.ptszPopupName = LPGENT("Sessions Manager");
	cl.icolibItem = iconList[0].hIcolib;
	cl.pszService = MS_SESSIONS_SAVEUSERSESSION;
	hmSaveCurrentSession = Menu_AddMainMenuItem(&cl);

	cl.ptszName = LPGENT("Load session...");
	cl.pszService = MS_SESSIONS_OPENMANAGER;
	cl.icolibItem = iconList[3].hIcolib;
	hmLoadLastSession = Menu_AddMainMenuItem(&cl);

	cl.ptszName = LPGENT("Close session");
	cl.pszService = MS_SESSIONS_CLOSESESSION;
	cl.icolibItem = 0;
	hmLoadSession = Menu_AddMainMenuItem(&cl);

	cl.ptszName = LPGENT("Load last session");
	cl.pszService = MS_SESSIONS_RESTORELASTSESSION;
	cl.icolibItem = iconList[5].hIcolib;
	cl.position = 10100000;
	hmLoadSession = Menu_AddMainMenuItem(&cl);

	ZeroMemory(&cl, sizeof(cl));
	cl.cbSize = sizeof(cl);
	cl.flags = CMIM_ICON;
	cl.icolibItem = iconList[4].hIcolib;
	Menu_ModifyItem(hmSaveCurrentSession, &cl);

	return 0;
}
Example #20
0
// Called when all the modules are loaded
static int ModulesLoaded(WPARAM, LPARAM)
{
	variables_enabled = ServiceExists(MS_VARS_FORMATSTRING);

	// Folders plugin support
	if (hDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Dictionaries"), DICTIONARIES_FOLDER)) {
		dictionariesFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH);
		FoldersGetCustomPathT(hDictionariesFolder, dictionariesFolder, MAX_PATH, _T("."));
	}
	else dictionariesFolder = Utils_ReplaceVarsT(DICTIONARIES_FOLDER);

	if (hCustomDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Custom Dictionaries"), CUSTOM_DICTIONARIES_FOLDER)) {
		customDictionariesFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH);
		FoldersGetCustomPathT(hCustomDictionariesFolder, customDictionariesFolder, MAX_PATH, _T("."));
	}
	else customDictionariesFolder = Utils_ReplaceVarsT(CUSTOM_DICTIONARIES_FOLDER);

	if (hFlagsDllFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Flags DLL"), FLAGS_DLL_FOLDER)) {
		flagsDllFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH);
		FoldersGetCustomPathT(hFlagsDllFolder, flagsDllFolder, MAX_PATH, _T("."));
	}
	else flagsDllFolder = Utils_ReplaceVarsT(FLAGS_DLL_FOLDER);

	InitOptions();

	GetAvaibleDictionaries(languages, dictionariesFolder, customDictionariesFolder);

	LoadOptions();

	if (opts.use_flags) {
		// Load flags dll
		TCHAR flag_file[MAX_PATH];
		mir_sntprintf(flag_file, _T("%s\\flags_icons.dll"), flagsDllFolder);
		HMODULE hFlagsDll = LoadLibraryEx(flag_file, NULL, LOAD_LIBRARY_AS_DATAFILE);

		TCHAR path[MAX_PATH];
		GetModuleFileName(hInst, path, MAX_PATH);

		SKINICONDESC sid = { 0 };
		sid.flags = SIDF_ALL_TCHAR | SIDF_SORTED;
		sid.section.t = LPGENT("Spell Checker") _T("/") LPGENT("Flags");

		// Get language flags
		for (int i = 0; i < languages.getCount(); i++) {
			Dictionary *p = languages[i];
			sid.description.t = p->full_name;

			char lang[32];
			mir_snprintf(lang, "spell_lang_%d", i);
			sid.pszName = lang;

			HICON hFlag = NULL, hFlagIcoLib = NULL;
			if (hFlagsDll != NULL)
				hFlag = (HICON)LoadImage(hFlagsDll, p->language, IMAGE_ICON, 16, 16, 0);

			if (hFlag != NULL) {
				sid.hDefaultIcon = hFlag;
				sid.defaultFile.t = NULL;
				sid.iDefaultIndex = 0;
			}
			else {
				hFlagIcoLib = IcoLib_GetIcon("spellchecker_unknown");
				sid.hDefaultIcon = hFlagIcoLib;
				sid.defaultFile.t = NULL;
				sid.iDefaultIndex = 0;
			}

			// Oki, lets add to IcoLib, then
			p->hIcolib = IcoLib_AddIcon(&sid);

			if (hFlag != NULL)
				DestroyIcon(hFlag);
			else
				IcoLib_ReleaseIcon(hFlagIcoLib);
		}
		FreeLibrary(hFlagsDll);
	}

	for (int j = 0; j < languages.getCount(); j++) {
		Dictionary *dict = languages[j];

		TCHAR filename[MAX_PATH];
		mir_sntprintf(filename, _T("%s\\%s.ar"), customDictionariesFolder, dict->language);
		dict->autoReplace = new AutoReplaceMap(filename, dict);

		if (mir_tstrcmp(dict->language, opts.default_language) == 0)
			dict->load();
	}

	HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
	HookEvent(ME_MSG_WINDOWEVENT, MsgWindowEvent);
	HookEvent(ME_MSG_WINDOWPOPUP, MsgWindowPopup);
	HookEvent(ME_MSG_ICONPRESSED, IconPressed);

	StatusIconData sid = { sizeof(sid) };
	sid.szModule = MODULE_NAME;
	sid.hIconDisabled = IcoLib_GetIcon("spellchecker_disabled");
	sid.flags = MBF_TCHAR | MBF_HIDDEN;

	for (int i = 0; i < languages.getCount(); i++) {
		sid.dwId = i;

		TCHAR tmp[128];
		mir_sntprintf(tmp, _T("%s - %s"), TranslateT("Spell Checker"), languages[i]->full_name);
		sid.tszTooltip = tmp;
		sid.hIcon = (opts.use_flags) ? IcoLib_GetIconByHandle(languages[i]->hIcolib) : IcoLib_GetIcon("spellchecker_enabled");
		Srmm_AddIcon(&sid);
	}

	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszName = "Spell Checker/Toggle";
	hkd.pszSection = LPGEN("Spell Checker");
	hkd.pszDescription = LPGEN("Enable/disable spell checker");
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_ALT, 'S');
	hkd.lParam = HOTKEY_ACTION_TOGGLE;
	Hotkey_Register(&hkd);

	loaded = TRUE;

	return 0;
}
Example #21
0
static int ModulesLoaded(WPARAM, LPARAM)
{
	char temp[MAX_PATH];
	CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)_countof(temp), (LPARAM)temp);
	crs_a2t(vertxt, temp);

	if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) {
		replaceStrT(profpath, _T("%miranda_userdata%"));

		// Removed because it isn't available on Load()
		//		hCrashLogFolder = FoldersRegisterCustomPathT(PluginName, LPGEN("Crash Reports"), CrashLogFolder);
		hVerInfoFolder = FoldersRegisterCustomPathT(PluginName, LPGEN("Version Information"), VersionInfoFolder);

		HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged);
		FoldersPathChanged(0, 0);
	}

	CMenuItem mi;
	mi.root = Menu_CreateRoot(MO_MAIN, LPGENT("Version Information"), 2000089999, GetIconHandle(IDI_VI));

	SET_UID(mi, 0x52930e40, 0xb2ee, 0x4433, 0xad, 0x77, 0xf5, 0x42, 0xe, 0xf6, 0x57, 0xc1);
	mi.position = 2000089995;
	mi.name.a = LPGEN("Copy to clipboard");
	mi.hIcolibItem = GetIconHandle(IDI_VITOCLIP);
	mi.pszService = MS_CRASHDUMPER_STORETOCLIP;
	Menu_AddMainMenuItem(&mi);

	SET_UID(mi, 0x54109094, 0x494e, 0x4535, 0x9c, 0x3a, 0xf6, 0x9e, 0x9a, 0xf7, 0xcd, 0xbe);
	mi.position = 2000089996;
	mi.name.a = LPGEN("Store to file");
	mi.hIcolibItem = GetIconHandle(IDI_VITOFILE);
	mi.pszService = MS_CRASHDUMPER_STORETOFILE;
	Menu_AddMainMenuItem(&mi);

	SET_UID(mi, 0x4004f9ee, 0x2c5a, 0x420a, 0xb1, 0x54, 0x3e, 0x47, 0xc1, 0xde, 0x46, 0xec);
	mi.position = 2000089997;
	mi.name.a = LPGEN("Show");
	mi.hIcolibItem = GetIconHandle(IDI_VISHOW);
	mi.pszService = MS_CRASHDUMPER_VIEWINFO;
	Menu_AddMainMenuItem(&mi);

	SET_UID(mi, 0x8526469a, 0x8ab4, 0x4dd4, 0xad, 0xbf, 0x51, 0xfd, 0x71, 0x10, 0xd3, 0x3c);
	mi.position = 2000089998;
	mi.name.a = LPGEN("Show with DLLs");
	mi.hIcolibItem = GetIconHandle(IDI_VIUPLOAD);
	mi.pszService = MS_CRASHDUMPER_VIEWINFO;
	Menu_ConfigureItem(Menu_AddMainMenuItem(&mi), MCI_OPT_EXECPARAM, 1);

	SET_UID(mi, 0xc6e3b558, 0xe1e8, 0x4cce, 0x96, 0x8, 0xc6, 0x89, 0x1b, 0x79, 0xf3, 0x7e);
	mi.position = 2000089999;
	mi.name.a = LPGEN("Upload");
	mi.hIcolibItem = GetIconHandle(IDI_VIUPLOAD);
	mi.pszService = MS_CRASHDUMPER_UPLOAD;
	Menu_AddMainMenuItem(&mi);

	SET_UID(mi, 0xa23da95a, 0x7624, 0x4343, 0x8c, 0xc0, 0xa6, 0x16, 0xbc, 0x30, 0x13, 0x8c);
	mi.position = 2000089999;
	mi.name.a = LPGEN("Copy link to clipboard");
	mi.hIcolibItem = GetIconHandle(IDI_LINKTOCLIP);//need icon
	mi.pszService = MS_CRASHDUMPER_URLTOCLIP;
	Menu_AddMainMenuItem(&mi);

	if (catchcrashes && !needrestart) {
		SET_UID(mi, 0xecae52f2, 0xd601, 0x4f85, 0x87, 0x9, 0xec, 0x8e, 0x84, 0xfe, 0x1b, 0x3c);
		mi.position = 2000099990;
		mi.name.a = LPGEN("Open crash report directory");
		mi.hIcolibItem = Skin_GetIconHandle(SKINICON_EVENT_FILE);
		mi.pszService = MS_CRASHDUMPER_URL;
		Menu_AddMainMenuItem(&mi);
	}

	SET_UID(mi, 0x6b19be3, 0xfb7d, 0x457d, 0x85, 0xde, 0xe0, 0x26, 0x4c, 0x87, 0x35, 0xf4);
	mi.position = 2000099991;
	mi.name.a = LPGEN("Open online Version Info");
	mi.hIcolibItem = Skin_GetIconHandle(SKINICON_EVENT_URL);
	mi.pszService = MS_CRASHDUMPER_URL;
	Menu_ConfigureItem(Menu_AddMainMenuItem(&mi), MCI_OPT_EXECPARAM, 1);

	HOTKEYDESC hk = { 0 };
	hk.cbSize = sizeof(hk);
	hk.pszSection = PluginName;

	hk.pszDescription = LPGEN("Copy Version Info to clipboard");
	hk.pszName = "CopyVerInfo";
	hk.pszService = MS_CRASHDUMPER_STORETOCLIP;
	Hotkey_Register(&hk);

	hk.pszDescription = LPGEN("Show Version Info");
	hk.pszName = "ShowVerInfo";
	hk.pszService = MS_CRASHDUMPER_VIEWINFO;
	Hotkey_Register(&hk);

	UploadInit();

	if (catchcrashes && !needrestart)
		SetExceptionHandler();

	HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded);

	if (servicemode)
		ViewVersionInfo(0, 0);
	else if (db_get_b(NULL, PluginName, "UploadChanged", 0) && !ProcessVIHash(false))
		UploadVersionInfo(0, 0xa1);

	return 0;
}
Example #22
0
int InitVariables( WPARAM wParam, LPARAM lParam )
{
	int j=0;
	int i=0;
	localeID = CallService(MS_LANGPACK_GETLOCALE,0,0);
	if (localeID==CALLSERVICE_NOTFOUND) localeID=LOCALE_USER_DEFAULT;
	codePage = CallService(MS_LANGPACK_GETCODEPAGE,0,0);
	if (codePage==CALLSERVICE_NOTFOUND) codePage=CP_ACP;
#ifdef UNICODE
	HasAwayMessageW = (ServiceExists(MS_AWAYMSG_GETSTATUSMSGW)!=0);
#endif
	for (i=0;i<4;i++) {
		Hotkey_Register(&hotkeydescs[i]);
	}


#ifdef AALOG
	{
	    NETLIBUSER nlu = { 0 };
	    nlu.cbSize = sizeof(nlu);
		nlu.szSettingsModule = "SAA";
		nlu.flags=NUF_NOOPTIONS | NUF_NOHTTPSOPTION;
	    nlu.szDescriptiveName = Translate(SECTIONNAME " Module");
		hNetlib = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
	}
	{
		SYSTEMTIME st={0};
		int drift;
		char str[32];
		char log[1024];
		char target[1024];
		drift = GetTimeZone(str);
		GetLastActiveLocalTime(&st,0);
		sprintf(log,"Now is %02d/%02d/%02d %02d:%02d:%02d %s (%02d:%02d)",
        st.wYear, st.wMonth, st.wDay,
        st.wHour, st.wMinute, st.wSecond,str,
		div(drift,60).quot,drift<0?-div(drift,60).rem:div(drift,60).rem);
		CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)log);
		GetLastActiveLocalTime(&st,24*60*60*1000);
		sprintf(log,"1 day ago was %02d/%02d/%02d %02d:%02d:%02d %s (%02d:%02d)",
        st.wYear, st.wMonth, st.wDay,
        st.wHour, st.wMinute, st.wSecond,str,
		div(drift,60).quot,drift<0?-div(drift,60).rem:div(drift,60).rem);
		CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)log);
		ParseString("%Y-%m-%d %H:%M:%S",target,1023);
		sprintf(log,"Testing ParseString: %s",target);
		CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)log);
		ParseString("%E/%d/%y %W %h:%M:%S %p",target,1023);
		sprintf(log,"Testing ParseString: %s",target);
		CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)log);
		ParseString("%w %% %Z (%z)%n%L%b%l%b%K%b%k",target,1023);
		sprintf(log,"Testing ParseString: %s",target);
		CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)log);
	}
#endif

	CallService(MS_PROTO_ENUMACCOUNTS,(WPARAM)&protoCount,(LPARAM)&accounts);
	reqStatus = (int *)mir_alloc((protoCount)*sizeof(reqStatus[0]));
	courStatus = (int *)mir_alloc((protoCount)*sizeof(courStatus[0]));
	courAwayStatus = (int *)mir_alloc((protoCount)*sizeof(courStatus[0]));
	protoModes = (int *)mir_alloc((protoCount)*sizeof(protoModes[0]));
	messCaps = (int *)mir_alloc((protoCount)*sizeof(messCaps[0]));

	awayStatuses=(short int *)mir_alloc((protoCount)*sizeof(awayStatuses[0]));
	onlyIfBits=(long int *)mir_alloc((protoCount)*sizeof(onlyIfBits[0]));
	awayStatusesPerm=(short int *)mir_alloc((protoCount)*sizeof(awayStatuses[0]));
	onlyIfBitsPerm=(long int *)mir_alloc((protoCount)*sizeof(onlyIfBits[0]));

	reconnectOpts=(long int *)mir_alloc((protoCount)*sizeof(reconnectOpts[0]));
	reconnectOptsPerm=(long int *)mir_alloc((protoCount)*sizeof(reconnectOptsPerm[0]));
	protoOfflineTimes=(unsigned int *)mir_alloc((protoCount)*sizeof(protoOfflineTimes[0]));
	protoStatus=(int *)mir_alloc((protoCount)*sizeof(protoStatus[0]));

	idleMessOpts=(long int *)mir_alloc((protoCount)*sizeof(idleMessOpts[0]));
	idleMessOptsPerm=(long int *)mir_alloc((protoCount)*sizeof(idleMessOptsPerm[0]));

	mesgHere = (TCHAR**)mir_alloc(protoCount * sizeof(mesgHere[0]));
	mesgHerePerm = (TCHAR**)mir_alloc(protoCount * sizeof(mesgHerePerm[0]));
	mesgShort = (TCHAR**)mir_alloc(protoCount * sizeof(mesgShort[0]));
	mesgShortPerm = (TCHAR**)mir_alloc(protoCount * sizeof(mesgShortPerm[0]));
	mesgLong = (TCHAR**)mir_alloc(protoCount * sizeof(mesgLong[0]));
	mesgLongPerm = (TCHAR**)mir_alloc(protoCount * sizeof(mesgLongPerm[0]));

	#ifdef UNICODE
		protoHasAwayMessageW=(bool *)mir_alloc(protoCount * sizeof(protoHasAwayMessageW[0]));
	#endif

	isWaitingForRestoreStatusMessage = (int *)mir_alloc((protoCount)*sizeof(isWaitingForRestoreStatusMessage[0]));

	for (j = 0 ; j < protoCount ; j++) {
		int caps=0;
#ifdef AALOG
			{
				char log[1024];
				sprintf(log,"Checking protocol index %d out of %d...",j+1,protoCount);
				CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)log);
			}
#endif
		reqStatus[j] = 0;
		courStatus[j] = ID_STATUS_OFFLINE;
		protoModes[j] =0;
		isWaitingForRestoreStatusMessage[j] = 0;
		caps = CallProtoService(accounts[j]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
		messCaps[j] = (CallProtoService(accounts[j]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)?
		CallProtoService(accounts[j]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0):0;
#ifdef AALOG
		{
			char log[1024];
			if (messCaps[j]){
				int i;
				sprintf(log,"StatusMessages Caps for %s:",
					accounts[j]->szModuleName
				);
				for (i=0;i<10;i++){
					int statusFlag = Proto_Status2Flag(aa_Status[i]);
					if (statusFlag & messCaps[j]){
						sprintf(log,"%s %s",log,CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, aa_Status[i], 0));
					}
				}
			} else {
				sprintf(log,"%s cannot set StatusMessage",
					accounts[j]->szModuleName);
			}
			CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)log);
		}
#endif
		for (i = 0; i<numStatuses; i++){
			protoModes[j] <<= 1;
			protoModes[j] |= (Proto_Status2Flag(aa_Status[i]) & caps)?1:0;
			protoModes[j] |= (aa_Status[i] == ID_STATUS_OFFLINE);
		}
		if ( isInterestingProto(j) ) {
			char str[256];
			sprintf(str,AA_BITSONLYIF,accounts[j]->szModuleName);
//			MessageBox(	0,str,accounts[j]->szModuleName,0);
			onlyIfBits[j]= db_get_dw(NULL,AA_MODULE,str,-1);
			if (onlyIfBits[j]==-1){
//				onlyIfBits[j] = (((protoModes[j]<<16)|(protoModes[j])) & aa_OnlyIfBitsDefault);
				onlyIfBits[j] =  aa_OnlyIfBitsDefault;
				db_set_dw(NULL,AA_MODULE,str,onlyIfBits[j]);
			}
			onlyIfBitsPerm[j]=onlyIfBits[j];
#ifdef UNICODE
			sprintf(str,"%s%s",accounts[j]->szModuleName,PS_SETAWAYMSGW);
			protoHasAwayMessageW[j]=(ServiceExists(str)!=0);
#endif
//			sprintf(str,AA_BITSLONGONLYIF,accounts[j]->szModuleName);
////			MessageBox(	0,str,accounts[j]->szModuleName,0);
//			if (!db_get_w(NULL,AA_MODULE,str,0))
//				db_set_w(NULL,AA_MODULE,str,(protoModes[j] & aa_OnlyIfBitsDefault)|known);
			sprintf(str,AA_AWAYSTATUSES,accounts[j]->szModuleName);
//			MessageBox(	0,str,accounts[j]->szModuleName,0);
			awayStatuses[j] = db_get_w(NULL,AA_MODULE,str,-1);
			if (awayStatuses[j] ==-1){
				int old = db_get_w(NULL,AA_OLDMODULE,AA_SHORTSTATUS,-1);
				int s = StatusToProtoIndex(((old==-1)?ID_STATUS_AWAY:OldIndexToStatus(old)),protoModes[j]);
				int l = 0;
				int comb = 0;
				old = db_get_w(NULL,AA_OLDMODULE,AA_LONGSTATUS,-1);
				l = StatusToProtoIndex(((old==-1)?ID_STATUS_NA:OldIndexToStatus(old)),protoModes[j]);
				comb = (l<<4)|s;
				old = db_get_b(NULL,AA_OLDMODULE,AA_USESHORT,-1);
				if (s) comb |= ((old==-1)?1<<8:(old==1)<<8);
				old = db_get_b(NULL,AA_OLDMODULE,AA_USELONG,-1);
				if (l) comb |= ((old==-1)?1<<9:(old==1)<<9);
//				comb |= (1<<15);
				awayStatuses[j]=comb;
				db_set_w(NULL,AA_MODULE,str,(WORD)awayStatuses[j]);
			}
			awayStatusesPerm[j] = awayStatuses[j];

			sprintf(str,AA_LASTREQUESTEDSTATUS,accounts[j]->szModuleName); //get last requested status
			reqStatus[j] = db_get_w(NULL,AA_MODULE,str,ID_STATUS_ONLINE); //default: online

			sprintf(str,AA_RECONNECTOPTS,accounts[j]->szModuleName); //get reconnect options status
			reconnectOpts[j] = db_get_dw(NULL,AA_MODULE,str,aa_ReconnectOptsDefault);
			reconnectOptsPerm[j] = reconnectOpts[j];
			protoStatus[j] = 0;
			protoOfflineTimes[j] = 0;
			mesgHere[j]=(TCHAR *)mir_alloc(sizeof(TCHAR)*(maxMessageLength+1));
			mesgHerePerm[j]=(TCHAR *)mir_alloc(sizeof(TCHAR)*(maxMessageLength+1));
			mesgShort[j]=(TCHAR *)mir_alloc(sizeof(TCHAR)*(maxMessageLength+1));
			mesgShortPerm[j]=(TCHAR *)mir_alloc(sizeof(TCHAR)*(maxMessageLength+1));
			mesgLong[j]=(TCHAR *)mir_alloc(sizeof(TCHAR)*(maxMessageLength+1));
			mesgLongPerm[j]=(TCHAR *)mir_alloc(sizeof(TCHAR)*(maxMessageLength+1));

			if (messCaps[j]){
				DBVARIANT dbv;
				sprintf(str,idleMsgOptionsName,accounts[j]->szModuleName);
				idleMessOptsPerm[j] = idleMessOpts[j] = db_get_dw(NULL,AA_MODULE,str,idleMsgOptionsDefault);

				sprintf(str,idleMsgOptionsTextHere,accounts[j]->szModuleName);
				if(db_get_ts(NULL,AA_MODULE,str,&dbv)==0) {
					_tcsncpy(mesgHere[j],dbv.ptszVal,maxMessageLength);
					mesgHere[j][maxMessageLength]=0;
					db_free(&dbv);
				} else _tcscpy(mesgHere[j],messHereDefault);
				if(!_tcscmp(mesgHere[j],messHereDefaultOld)) _tcscpy(mesgHere[j],messHereDefault);
				_tcscpy(mesgHerePerm[j],mesgHere[j]);

				sprintf(str,idleMsgOptionsTextShort,accounts[j]->szModuleName);
				if(db_get_ts(NULL,AA_MODULE,str,&dbv)==0) {
					_tcsncpy(mesgShort[j],dbv.ptszVal,maxMessageLength);
					mesgShort[j][maxMessageLength]=0;
					db_free(&dbv);
				} else _tcscpy(mesgShort[j],messShortDefault);
				if(!_tcscmp(mesgShort[j],messShortDefaultOld)) _tcscpy(mesgShort[j],messShortDefault);
				_tcscpy(mesgShortPerm[j],mesgShort[j]);

				sprintf(str,idleMsgOptionsTextLong,accounts[j]->szModuleName);
				if(db_get_ts(NULL,AA_MODULE,str,&dbv)==0) {
					_tcsncpy(mesgLong[j],dbv.ptszVal,maxMessageLength);
					mesgLong[j][maxMessageLength]=0;
					db_free(&dbv);
				} else _tcscpy(mesgLong[j],messLongDefault);
				if(!_tcscmp(mesgLong[j],messLongDefaultOld)) _tcsncpy(mesgLong[j],messLongDefault,maxMessageLength);
				_tcsncpy(mesgLongPerm[j],mesgLong[j],maxMessageLength);
//				sprintf(mesgHere[j],"%d: %s: %s",j,accounts[j]->szModuleName,"Test text");
			} else {
				idleMessOptsPerm[j] = idleMessOpts[j] = 0;
				mesgHerePerm[j] = mesgHere[j] = mesgShortPerm[j] = mesgShort[j] = mesgLongPerm[j] = mesgLong[j] = NULL;
			}
		}
	}
#ifdef AALOG
	{
		char str[1024]="";
		for (j = 0 ; j < protoCount ; j++) {
			int status;
			sprintf(str,"%s\n%s Type:%d\nLastReqStatus: %s\n",str,accounts[j]->szModuleName,accounts[j]->szProtoName,CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)reqStatus[j], 0));
			i=1;
			while(status=StatusByProtoIndex(protoModes[j],i)){
				sprintf(str,"%s  %d. %s\n",str,i,CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, 0));
				i++;
			}
//					IsStatusBitSet(aa_Status[i],protoModes[j])?"":"not",
//					CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)aa_Status[i], 0),
//					IsStatusBitSet(aa_Status[i],aa_OnlyIfBitsDefault)?"n":"ff"
//				);

		}
		CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)str);
	}
#endif
//something is hapaning here on startup, if main status is not offline
//will move Notify hIdleEvent for later in the IdleTimer
//	NotifyEventHooks( hIdleEvent, 0, idleOpts&IdleBitsPrivate?IDF_PRIVACY:0 ); //Tell everyone we are here
	FirstTick = 1; //we will wait 1 ticks of the timer before Forcing Awake
//	FirstTick = 10; //we will wait 20 seconds before Forcing Awake
	hIdleTimer=SetTimer(NULL, 0, 2000, IdleTimer);
//	{
//		char str[20000]="";
//		for (i=0;i<=101;i++){
//			char str1[128];
//			GetStringFromDelay(str1,GetReconnectDelayFromSlider(i));
//			sprintf(str,"%d\t%d\t%s",GetReconnectDelayFromSlider(i),i,str1);
//			CallService("Netlib/Log" ,(WPARAM)hNetlib ,(LPARAM)str);
//		}
//	}
	if ((idleOptsPerm&IdleSuppressIdleMenu)==0) AddIdleMenu();
	if ((idleOptsPerm&IdleSuppressAutoHere)!=0) isCurrentlyIdle=db_get_b(NULL,AA_MODULE,AA_LASTIDLESTATUS,0);;
	return 0;
}
Example #23
0
int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
	HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged);
	HookEvent(ME_TTB_MODULELOADED, OnTopToolBarModuleLoaded);
	
	SkinAddNewSoundExT(BIRTHDAY_NEAR_SOUND, LPGENT("WhenWasIt"), LPGENT("Birthday near"));
	SkinAddNewSoundExT(BIRTHDAY_TODAY_SOUND, LPGENT("WhenWasIt"), LPGENT("Birthday today"));
	
	UpdateTimers();

	CLISTMENUITEM cl = { sizeof(cl) };
	cl.position = 10000000;
	cl.pszPopupName = LPGEN("Birthdays (When Was It)");

	cl.pszService = MS_WWI_CHECK_BIRTHDAYS;
	cl.icolibItem = hCheckMenu;
	cl.pszName = LPGEN("Check for birthdays");
	hmCheckBirthdays = Menu_AddMainMenuItem(&cl);
	
	cl.pszService = MS_WWI_LIST_SHOW;
	cl.pszName = LPGEN("Birthday list");
	cl.icolibItem = hListMenu;
	hmBirthdayList = Menu_AddMainMenuItem(&cl);
	
	cl.pszService = MS_WWI_REFRESH_USERDETAILS;
	cl.position = 10100000;
	cl.pszName = LPGEN("Refresh user details");
	cl.icolibItem = hRefreshUserDetails;
	hmRefreshDetails = Menu_AddMainMenuItem(&cl);
	
	cl.pszService = MS_WWI_IMPORT_BIRTHDAYS;
	cl.position = 10200000;
	cl.pszName = LPGEN("Import birthdays");
	cl.icolibItem = hImportBirthdays;
	hmImportBirthdays = Menu_AddMainMenuItem(&cl);
	
	cl.pszService = MS_WWI_EXPORT_BIRTHDAYS;
	cl.pszName = LPGEN("Export birthdays");
	cl.icolibItem = hExportBirthdays;
	hmExportBirthdays = Menu_AddMainMenuItem(&cl);
	
	cl.pszService = MS_WWI_ADD_BIRTHDAY;
	cl.position = 10000000;
	cl.icolibItem = hAddBirthdayContact;
	cl.pszName = LPGEN("Add/change user &birthday");
	hmAddChangeBirthday = Menu_AddContactMenuItem(&cl);

	// Register hotkeys
	HOTKEYDESC hotkey = { sizeof(hotkey) };
	hotkey.pszSection = LPGEN("Birthdays");

	hotkey.pszName = "wwi_birthday_list";
	hotkey.pszDescription = LPGEN("Birthday list");
	hotkey.pszService = MS_WWI_LIST_SHOW;
	Hotkey_Register(&hotkey);
		
	hotkey.pszName = "wwi_check_birthdays";
	hotkey.pszDescription = LPGEN("Check for birthdays");
	hotkey.pszService = MS_WWI_CHECK_BIRTHDAYS;
	Hotkey_Register(&hotkey);
	
	return 0;
}
Example #24
0
extern "C" int __declspec(dllexport) Load(void)
{
	mir_getLP(&pluginInfo);

	YAMN_STATUS = ID_STATUS_OFFLINE;

	//	we get the Miranda Root Path
	PathToAbsoluteT( _T("."), szMirandaDir);

	// retrieve the current profile name
	CallService(MS_DB_GETPROFILENAMET, (WPARAM)_countof(ProfileName), (LPARAM)ProfileName);	//not to pass entire array to fcn
	TCHAR *fc = _tcsrchr(ProfileName, '.');
	if ( fc != NULL ) *fc = 0;

	//	we get the user path where our yamn-account.book.ini is stored from mirandaboot.ini file
	GetProfileDirectory(UserDirectory, _countof(UserDirectory));

	// Enumerate all the code pages available for the System Locale
	EnumSystemCodePages(EnumSystemCodePagesProc, CP_INSTALLED);
	CodePageNamesSupp = new _tcptable[CPLENSUPP];
	for (int i = 0, k = 0; i < CPLENALL; i++) {
		if (CodePageNamesAll[i].isValid) {
			CodePageNamesSupp[k] = CodePageNamesAll[i];
			k++;
	}	}

	// Registering YAMN as protocol
	PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
	pd.szName = YAMN_DBMODULE;
	pd.type = PROTOTYPE_VIRTUAL;
	Proto_RegisterModule(&pd);

	InitializeCriticalSection(&AccountStatusCS);
	InitializeCriticalSection(&FileWritingCS);
	InitializeCriticalSection(&PluginRegCS);

	if (NULL == (NoWriterEV = CreateEvent(NULL, TRUE, TRUE, NULL)))
		return 1;
	if (NULL == (WriteToFileEV = CreateEvent(NULL, FALSE, FALSE, NULL)))
		return 1;
	if (NULL == (ExitEV = CreateEvent(NULL, TRUE, FALSE, NULL)))
		return 1;

	PosX = db_get_dw(NULL, YAMN_DBMODULE, YAMN_DBPOSX, 0);
	PosY = db_get_dw(NULL, YAMN_DBMODULE, YAMN_DBPOSY, 0);
	SizeX = db_get_dw(NULL, YAMN_DBMODULE, YAMN_DBSIZEX, 800);
	SizeY = db_get_dw(NULL, YAMN_DBMODULE, YAMN_DBSIZEY, 200);

	HeadPosX = db_get_dw(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSX, 0);
	HeadPosY = db_get_dw(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSY, 0);
	HeadSizeX = db_get_dw(NULL, YAMN_DBMODULE, YAMN_DBMSGSIZEX, 690);
	HeadSizeY = db_get_dw(NULL, YAMN_DBMODULE, YAMN_DBMSGSIZEY, 300);
	HeadSplitPos = db_get_w(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSSPLIT, 250);

	optDateTime = db_get_b(NULL, YAMN_DBMODULE, YAMN_DBTIMEOPTIONS, optDateTime);

	// Create new window queues for broadcast messages
	YAMNVar.MessageWnds = WindowList_Create();
	YAMNVar.NewMailAccountWnd = WindowList_Create();
	YAMNVar.Shutdown = FALSE;

	hCurSplitNS = LoadCursor(NULL, IDC_SIZENS);
	hCurSplitWE = LoadCursor(NULL, IDC_SIZEWE);

#ifdef _DEBUG
	InitDebug();
#endif

	CreateServiceFunctions();

	SkinAddNewSoundEx(YAMN_NEWMAILSOUND, YAMN_DBMODULE, YAMN_NEWMAILSNDDESC);
	SkinAddNewSoundEx(YAMN_CONNECTFAILSOUND, YAMN_DBMODULE, YAMN_CONNECTFAILSNDDESC);

	HookEvents();

	LoadIcons();
	LoadPlugins();

	HOTKEYDESC hkd = {0};
	hkd.cbSize = sizeof(hkd);
	hkd.pszName = "YAMN_hotkey";
	hkd.pszService = MS_YAMN_FORCECHECK;
	hkd.pszSection = YAMN_DBMODULE;
	hkd.pszDescription = LPGEN("Check mail");
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F11);
	Hotkey_Register(&hkd);

	//Create thread that will be executed every second
	if (!(SecTimer = SetTimer(NULL, 0, 1000, TimerProc)))
		return 1;

	return 0;
}
Example #25
0
void InitCustomMenus(void)
{
	CreateServiceFunction("MainMenuExecService", MainMenuExecService);

	CreateServiceFunction("ContactMenuExecService", ContactMenuExecService);
	CreateServiceFunction("ContactMenuCheckService", ContactMenuCheckService);

	CreateServiceFunction("StatusMenuExecService", StatusMenuExecService);
	CreateServiceFunction("StatusMenuCheckService", StatusMenuCheckService);

	//free services
	CreateServiceFunction("CLISTMENUS/FreeOwnerDataMainMenu", FreeOwnerDataMainMenu);
	CreateServiceFunction("CLISTMENUS/FreeOwnerDataContactMenu", FreeOwnerDataContactMenu);
	CreateServiceFunction("CLISTMENUS/FreeOwnerDataStatusMenu", FreeOwnerDataStatusMenu);

	CreateServiceFunction(MS_CLIST_SETSTATUSMODE, SetStatusMode);

	CreateServiceFunction("CList/AddMainMenuItem", AddMainMenuItem);
	CreateServiceFunction("CList/AddStatusMenuItem", AddStatusMenuItem);
	CreateServiceFunction(MS_CLIST_MENUGETMAIN, MenuGetMain);
	CreateServiceFunction(MS_CLIST_MENUBUILDMAIN, BuildMainMenu);

	CreateServiceFunction("CList/AddContactMenuItem", AddContactMenuItem);
	CreateServiceFunction(MS_CLIST_MENUBUILDCONTACT, BuildContactMenu);

	CreateServiceFunction(MS_CLIST_SHOWHIDEMENUITEM, ShowHideMenuItem);
	CreateServiceFunction(MS_CLIST_MODIFYMENUITEM, ModifyCustomMenuItem);
	CreateServiceFunction(MS_CLIST_MENUMEASUREITEM, MeasureMenuItem);
	CreateServiceFunction(MS_CLIST_MENUDRAWITEM, DrawMenuItem);

	CreateServiceFunction(MS_CLIST_MENUGETSTATUS, BuildStatusMenu);
	CreateServiceFunction(MS_CLIST_MENUPROCESSCOMMAND, MenuProcessCommand);
	CreateServiceFunction(MS_CLIST_MENUPROCESSHOTKEY, MenuProcessHotkey);

	CreateServiceFunction("CList/AddProtoMenuItem", AddProtoMenuItem);

	hPreBuildContactMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDCONTACTMENU);
	hPreBuildMainMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDMAINMENU);
	cli.hPreBuildStatusMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDSTATUSMENU);
	hStatusModeChangeEvent = CreateHookableEvent(ME_CLIST_STATUSMODECHANGE);

	HookEvent(ME_PROTO_ACK, MenuProtoAck);

	hMainMenu = CreatePopupMenu();
	hStatusMenu = CreatePopupMenu();

	hStatusMainMenuHandles = NULL;
	hStatusMainMenuHandlesCnt = 0;

	hStatusMenuHandles = NULL;
	hStatusMenuHandlesCnt = 0;

	// new menu sys
	InitGenMenu();

	// main menu
	hMainMenuObject = MO_CreateMenuObject("MainMenu", LPGEN("Main menu"), 0, "MainMenuExecService");
	MO_SetOptionsMenuObject(hMainMenuObject, OPT_USERDEFINEDITEMS, TRUE);
	MO_SetOptionsMenuObject(hMainMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataMainMenu");

	// contact menu
	hContactMenuObject = MO_CreateMenuObject("ContactMenu", LPGEN("Contact menu"), "ContactMenuCheckService", "ContactMenuExecService");
	MO_SetOptionsMenuObject(hContactMenuObject, OPT_USERDEFINEDITEMS, TRUE);
	MO_SetOptionsMenuObject(hContactMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataContactMenu");

	// initialize hotkeys
	CreateServiceFunction(MS_CLIST_HKSTATUS, HotkeySetStatus);

	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.ptszSection = _T("Status");
	hkd.dwFlags = HKD_TCHAR;
	for (int i = 0; i < SIZEOF(statusHotkeys); i++) {
		char szName[30];
		mir_snprintf(szName, SIZEOF(szName), "StatusHotKey_%d", i);
		hkd.pszName = szName;
		hkd.lParam = statusModeList[i];
		hkd.ptszDescription = fnGetStatusModeDescription(hkd.lParam, 0);
		hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, '0' + i) | HKF_MIRANDA_LOCAL;
		hkd.pszService = MS_CLIST_HKSTATUS;
		statusHotkeys[i] = Hotkey_Register(&hkd);
	}

	HookEvent(ME_HOTKEYS_CHANGED, sttRebuildHotkeys);

	// add exit command to menu

	CLISTMENUITEM mi = { sizeof(mi) };
	mi.position = 0x7fffffff;
	mi.pszService = "CloseAction";
	mi.pszName = LPGEN("E&xit");
	mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_EXIT);
	AddMainMenuItem(0, (LPARAM)&mi);

	cli.currentStatusMenuItem = ID_STATUS_OFFLINE;
	cli.currentDesiredStatusMode = ID_STATUS_OFFLINE;

	HookEvent(ME_SKIN_ICONSCHANGED, MenuIconsChanged);
}
Example #26
0
extern "C" __declspec(dllexport) int Load(PLUGINLINK *link)
{
	pluginLink = link;
	mir_getMMI(&mmi);
	mir_getLI(&li);
	mir_getMD5I(&md5i);
	mir_getUTFI(&utfi);
#else
extern "C" __declspec(dllexport) int Load(void)
{
	mir_getLP(&pluginInfoEx);

	InitServices();
#endif

	db_set_b(NULL, MODNAME, "NeedRestart", 0);

	DWORD dwLen = GetTempPath( SIZEOF(tszTempPath), tszTempPath);
	if (tszTempPath[dwLen-1] == '\\')
		tszTempPath[dwLen-1] = 0;

	LoadOptions();
	InitPopupList();
	InitNetlib();
	InitIcoLib();

	// Add cheking update menu item
	InitCheck();
	CLISTMENUITEM mi = { sizeof(mi) };
	mi.position = 400010000;
	mi.icolibItem = Skin_GetIconHandle("check_update");
	mi.pszName = LPGEN("Check for updates");
	mi.pszService = MODNAME"/CheckUpdates";
	Menu_AddMainMenuItem(&mi);

#if MIRANDA_VER >= 0x0A00
	InitListNew();

	mi.position++;
	mi.icolibItem = Skin_GetIconHandle("plg_list");
	mi.pszName = LPGEN("Available components list");
	mi.pszService = MODNAME"/ShowList";
	Menu_AddMainMenuItem(&mi);

	InitOptions();
#endif

	// Add hotkey
	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszName = "Check for updates";
	hkd.pszDescription = "Check for updates";
	hkd.pszSection = "Plugin Updater";
	hkd.pszService = MODNAME"/CheckUpdates";
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F10) | HKF_MIRANDA_LOCAL;
	hkd.lParam = FALSE;
	Hotkey_Register(&hkd);

	InitEvents();

	//add sounds
	SkinAddNewSoundEx("updatecompleted",LPGEN("Plugin Updater"),LPGEN("Update completed"));
	SkinAddNewSoundEx("updatefailed",LPGEN("Plugin Updater"),LPGEN("Update failed"));
	return 0;
}
Example #27
0
static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam)
{
	CreateServiceFunction(MS_CONSOLE_SHOW_HIDE, ShowHideConsole);

	FontIDT fid = {0};
	fid.cbSize = sizeof(fid);
	_tcscpy(fid.group,_T("Console"));
	_tcscpy(fid.name,TranslateT("Text"));
	strcpy(fid.dbSettingsGroup,"Console");
	strcpy(fid.prefix,"ConsoleFont");
	_tcscpy(fid.backgroundGroup,_T("Console"));
	_tcscpy(fid.backgroundName,_T("Background"));
	fid.flags = FIDF_DEFAULTVALID;
	fid.deffontsettings.charset = DEFAULT_CHARSET;
	fid.deffontsettings.colour = RGB(0, 0, 0);
	fid.deffontsettings.size = 10;
	fid.deffontsettings.style = 0;
	_tcsncpy(fid.deffontsettings.szFace, _T("Courier"), LF_FACESIZE);
	FontRegisterT(&fid);

	HookEvent(ME_FONT_RELOAD,OnFontChange);

	ColourIDT cid = {0};
	cid.cbSize=sizeof(cid);
	_tcscpy(cid.group,_T("Console"));
	_tcscpy(cid.name,_T("Background"));
	strcpy(cid.dbSettingsGroup,"Console");
	strcpy(cid.setting,"BgColor");
	cid.defcolour = RGB(255,255,255);
	ColourRegisterT(&cid);

	HookEvent(ME_COLOUR_RELOAD, OnColourChange);

	HOTKEYDESC hkd = {0};
	hkd.cbSize = sizeof(hkd);
	hkd.pszName = "Console_Show_Hide";
	hkd.pszDescription = LPGEN("Show/Hide Console");
	hkd.pszSection = "Main";
	hkd.pszService = MS_CONSOLE_SHOW_HIDE;
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_EXT, 'C');
	Hotkey_Register(&hkd);

	if (hwndConsole && IsWindow(hwndConsole))
	{
		HookEvent(ME_TTB_MODULELOADED, OnTTBLoaded);

		CLISTMENUITEM mi = { sizeof(mi) };
		mi.flags = CMIF_TCHAR;
		mi.hIcon = hIcons[0];
		mi.ptszPopupName = LPGENT("&Help");
		mi.popupPosition = 2000090000;
		mi.position = 1000000000;
		mi.ptszName = (IsWindowVisible(hwndConsole)) ? LPGENT("Hide Console") : LPGENT("Show Console");
		mi.pszService = MS_CONSOLE_SHOW_HIDE;
		hMenu = Menu_AddMainMenuItem(&mi);

		OnFontChange(0,0);
		OnColourChange(0,0);

		if (db_get_b(NULL,"Console","ShowAtStart",0) || db_get_b(NULL,"Console","Show",1))
			ShowConsole(1);
		else
			ShowConsole(0);
	}

	return 0;
}