Exemplo n.º 1
0
static int CSStatusChangeEx(WPARAM wParam, LPARAM lParam)
{
	// another status plugin made the change
	if (!db_get_b(NULL, MODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0)
		return 0;

	if (wParam != 0) {
		PROTOCOLSETTINGEX** ps = *(PROTOCOLSETTINGEX***)wParam;
		if (ps == NULL)
			return -1;

		for (int i = 0; i < startupSettings.getCount(); i++) {
			for (int j = 0; j < startupSettings.getCount(); j++) {
				if (ps[i]->szName == NULL || startupSettings[j].szName == NULL)
					continue;

				if (!mir_strcmp(ps[i]->szName, startupSettings[j].szName)) {
					log_debugA("StartupStatus: %s overridden by MS_CS_SETSTATUSEX, status will not be set", ps[i]->szName);
					// use a hack to disable this proto
					startupSettings[j].szName = "";
				}
			}
		}
	}

	return 0;
}
Exemplo n.º 2
0
// 'allow override'
static int ProcessProtoAck(WPARAM wParam, LPARAM lParam)
{
	// 'something' made a status change
	ACKDATA *ack = (ACKDATA*)lParam;
	if (ack->type != ACKTYPE_STATUS && ack->result != ACKRESULT_FAILED)
		return 0;

	if (!db_get_b(NULL, MODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0)
		return 0;

	for (int i = 0; i < startupSettings.getCount(); i++) {
		if (!mir_strcmp(ack->szModule, startupSettings[i].szName)) {
			startupSettings[i].szName = "";
			log_debugA("StartupStatus: %s overridden by ME_PROTO_ACK, status will not be set", ack->szModule);
		}
	}

	return 0;
}
Exemplo n.º 3
0
static int StatusChange(WPARAM wParam, LPARAM lParam)
{
	// change by menu
	if (!db_get_b(NULL, MODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0)
		return 0;

	char *szProto = (char *)lParam;
	if (szProto == NULL) { // global status change
		for (int i = 0; i < startupSettings.getCount(); i++) {
			startupSettings[i].szName = "";
			log_debugA("StartupStatus: all protos overridden by ME_CLIST_STATUSMODECHANGE, status will not be set");
		}
	}
	else {
		for (int i = 0; i < startupSettings.getCount(); i++) {
			if (!mir_strcmp(startupSettings[i].szName, szProto)) {
				startupSettings[i].szName = "";
				log_debugA("StartupStatus: %s overridden by ME_CLIST_STATUSMODECHANGE, status will not be set", szProto);
			}
		}
	}

	return 0;
}
Exemplo n.º 4
0
static void SetLastStatusMessages(TSettingsList &ps)
{
	for (int i = 0; i < ps.getCount(); i++) {
		if (ps[i].status != ID_STATUS_LAST)
			continue;

		char dbSetting[128];
		mir_snprintf(dbSetting, "%s%s", PREFIX_LASTMSG, ps[i].szName);

		DBVARIANT dbv;
		if (ps[i].szMsg == NULL && !db_get_ts(NULL, MODULENAME, dbSetting, &dbv)) {
			ps[i].szMsg = _tcsdup(dbv.ptszVal); // remember this won't be freed
			db_free(&dbv);
		}
	}
}
Exemplo n.º 5
0
static void ProcessCommandLineOptions(TSettingsList& protoSettings)
{
	if (protoSettings.getCount() == 0)
		return;

	char *cmdl = GetCommandLineA();
	while (*cmdl != '\0') {
		while (*cmdl != '/') {
			if (*cmdl == '\0')
				return;

			cmdl++;
		}
		if (*cmdl == '\0')
			return;

		cmdl++;
		if (!strncmp(cmdl, "showdialog", 10)) {
			showDialogOnStartup = TRUE;
			continue;
		}
		char *protoName = cmdl; // first protocol ?
		PROTOCOLSETTINGEX* protoSetting = IsValidProtocol(protoSettings, protoName);
		if (protoSetting != NULL) {
			while (*cmdl != '=') {
				if (*cmdl == '\0')
					return;

				cmdl++; // skip to status
			}

			if (*cmdl == '\0')
				return;

			cmdl++;
			char *statusDesc = cmdl;
			int status = IsValidStatusDesc(statusDesc);
			if (status != 0)
				protoSetting->status = status;
		}
	}
}
Exemplo n.º 6
0
int OnAccChanged(WPARAM wParam, LPARAM lParam)
{
	PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam;
	switch (wParam) {
	case PRAC_ADDED:
		startupSettings.insert(new TSSSetting(-1, pa));
		break;

	case PRAC_REMOVED:
		for (int i = 0; i < startupSettings.getCount(); i++) {
			if (!mir_strcmp(startupSettings[i].szName, pa->szModuleName)) {
				startupSettings.remove(i);
				break;
			}
		}
		break;
	}

	return 0;
}
Exemplo n.º 7
0
int GetProfile( int profile, TSettingsList& arSettings )
{
    if ( profile < 0 ) // get default profile
        profile = db_get_w(NULL, MODULENAME, SETTING_DEFAULTPROFILE, 0);

    int count = db_get_w(NULL, MODULENAME, SETTING_PROFILECOUNT, 0);
    if ( profile >= count && count > 0 )
        return -1;

    arSettings.destroy();

    // if count == 0, continue so the default profile will be returned
    PROTOACCOUNT** protos;
    Proto_EnumAccounts( &count, &protos );

    for ( int i=0; i < count; i++ )
        if ( IsSuitableProto( protos[i] ))
            arSettings.insert( new TSSSetting( profile, protos[i] ));

    return ( arSettings.getCount() == 0 ) ? -1 : 0;
}
Exemplo n.º 8
0
int CSModuleLoaded(WPARAM wParam, LPARAM lParam)
{
	protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&startupSettings;

	InitProfileModule();

	HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccChanged);
	HookEvent(ME_OPT_INITIALISE, OptionsInit);

	/* shutdown hook for normal shutdown */
	HookEvent(ME_SYSTEM_OKTOEXIT, OnOkToExit);
	HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
	/* message window for poweroff */
	hMessageWindow = CreateWindowEx(0, _T("STATIC"), NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
	SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc);

	GetProfile(-1, startupSettings);

	// override with cmdl
	ProcessCommandLineOptions(startupSettings);
	if (startupSettings.getCount() == 0)
		return 0;// no protocols are loaded

	SetLastStatusMessages(startupSettings);
	showDialogOnStartup = (showDialogOnStartup || db_get_b(NULL, MODULENAME, SETTING_SHOWDIALOG, 0));

	// dial
	if (showDialogOnStartup || db_get_b(NULL, MODULENAME, SETTING_SETPROFILE, 1))
		if (db_get_b(NULL, MODULENAME, SETTING_AUTODIAL, 0))
			InternetAutodial(0, NULL);

	// set the status!
	if (showDialogOnStartup || db_get_b(NULL, MODULENAME, SETTING_SHOWDIALOG, 0))
		CallService(MS_CS_SHOWCONFIRMDLGEX, (WPARAM)&startupSettings, db_get_dw(NULL, MODULENAME, SETTING_DLGTIMEOUT, 5));
	else if (db_get_b(NULL, MODULENAME, SETTING_SETPROFILE, 1)) {
		// set hooks for override
		if (db_get_b(NULL, MODULENAME, SETTING_OVERRIDE, 1)) {
			hProtoAckHook = HookEvent(ME_PROTO_ACK, ProcessProtoAck);
			hCSStatusChangeHook = HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChangeEx);
			hStatusChangeHook = HookEvent(ME_CLIST_STATUSMODECHANGE, StatusChange);
		}
		setStatusTimerId = SetTimer(NULL, 0, db_get_dw(NULL, MODULENAME, SETTING_SETPROFILEDELAY, 500), SetStatusTimed);
	}

	// win size and location
	if (db_get_b(NULL, MODULENAME, SETTING_SETWINLOCATION, 0) || db_get_b(NULL, MODULENAME, SETTING_SETWINSIZE, 0)) {
		HWND hClist = pcli->hwndContactList;

		// store in db
		if (db_get_b(NULL, MODULENAME, SETTING_SETWINLOCATION, 0)) {
			db_set_dw(NULL, MODULE_CLIST, SETTING_XPOS, db_get_dw(NULL, MODULENAME, SETTING_XPOS, 0));
			db_set_dw(NULL, MODULE_CLIST, SETTING_YPOS, db_get_dw(NULL, MODULENAME, SETTING_YPOS, 0));
		}
		if (db_get_b(NULL, MODULENAME, SETTING_SETWINSIZE, 0)) {
			db_set_dw(NULL, MODULE_CLIST, SETTING_WIDTH, db_get_dw(NULL, MODULENAME, SETTING_WIDTH, 0));
			if (!db_get_b(NULL, MODULE_CLUI, SETTING_AUTOSIZE, 0))
				db_set_dw(NULL, MODULE_CLIST, SETTING_HEIGHT, db_get_dw(NULL, MODULENAME, SETTING_HEIGHT, 0));
		}

		WINDOWPLACEMENT wndpl = { sizeof(wndpl) };
		if (GetWindowPlacement(hClist, &wndpl)) {
			if (wndpl.showCmd == SW_SHOWNORMAL && !CallService(MS_CLIST_DOCKINGISDOCKED, 0, 0)) {
				RECT rc;
				if (GetWindowRect(hClist, &rc)) {
					int x = rc.left;
					int y = rc.top;
					int width = rc.right - rc.left;
					int height = rc.bottom - rc.top;
					if (db_get_b(NULL, MODULENAME, SETTING_SETWINLOCATION, 0)) {
						x = db_get_dw(NULL, MODULENAME, SETTING_XPOS, x);
						y = db_get_dw(NULL, MODULENAME, SETTING_YPOS, y);
					}
					if (db_get_b(NULL, MODULENAME, SETTING_SETWINSIZE, 0)) {
						width = db_get_dw(NULL, MODULENAME, SETTING_WIDTH, width);
						if (!db_get_b(NULL, MODULE_CLUI, SETTING_AUTOSIZE, 0))
							height = db_get_dw(NULL, MODULENAME, SETTING_HEIGHT, height);
					}
					MoveWindow(hClist, x, y, width, height, TRUE);
	}	}	}	}
	
	return 0;
}