Пример #1
0
static int PrebuildContactMenu(WPARAM wParam, LPARAM)
{
	MCONTACT hContact = wParam;
	if (hContact) {
		char *szProto = GetContactProto(hContact);
		PROTOACCOUNT *pa = Proto_GetAccount(szProto);
		Menu_ShowItem(hChangeSound, IsSuitableProto(pa));
	}
	return 0;
}
Пример #2
0
static int OnOkToExit(WPARAM, LPARAM)
{
	// save last protocolstatus
	int count;
	PROTOACCOUNT** protos;
	Proto_EnumAccounts(&count, &protos);

	for (int i = 0; i < count; i++) {
		PROTOACCOUNT *pa = protos[i];
		if (!IsSuitableProto(pa))
			continue;

		if (!Proto_GetAccount(pa->szModuleName))
			continue;

		char lastName[128], lastMsg[128];
		mir_snprintf(lastName, "%s%s", PREFIX_LAST, pa->szModuleName);
		db_set_w(NULL, MODULENAME, lastName, (WORD)CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0));
		mir_snprintf(lastMsg, "%s%s", PREFIX_LASTMSG, pa->szModuleName);
		db_unset(NULL, MODULENAME, lastMsg);

		if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0) & PF1_MODEMSGSEND & ~PF1_INDIVMODEMSG))
			continue;

		int status = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
		if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0) & Proto_Status2Flag(status)))
			continue;

		// NewAwaySys
		if (ServiceExists(MS_NAS_GETSTATE)) {
			NAS_PROTOINFO npi = { sizeof(npi) };
			npi.szProto = pa->szModuleName;
			CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1);
			if (npi.szMsg == NULL) {
				npi.status = 0;
				npi.szProto = NULL;
				CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1);
			}
			if (npi.szMsg != NULL) {
				db_set_ts(NULL, MODULENAME, lastMsg, npi.tszMsg);
				mir_free(npi.tszMsg);
			}
		}
	}

	if (db_get_b(NULL, MODULENAME, SETTING_SETPROFILE, 1) || db_get_b(NULL, MODULENAME, SETTING_OFFLINECLOSE, 0)) {
		if (ServiceExists(MS_CLIST_SETSTATUSMODE))
			CallService(MS_CLIST_SETSTATUSMODE, (WPARAM)ID_STATUS_OFFLINE, 0);
		else
			log_debugA("StartupStatus: MS_CLIST_SETSTATUSMODE not available!");
	}

	return 0;
}
Пример #3
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;
}