Exemplo n.º 1
0
int LoadSession(WPARAM, LPARAM lparam)
{
	int dup = 0;
	int hidden[255] = { '0' };
	MCONTACT hContact;
	MCONTACT session_list_t[255] = { 0 };
	int mode = 0;
	if ((int)lparam >= g_ses_limit && lparam != 256) {
		mode = 1;
		lparam -= g_ses_limit;
	}
	if (session_list_recovered[0] && lparam == 256 && mode == 0)
		memcpy(session_list_t, session_list_recovered, sizeof(session_list_t));
	else
		for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
			if (LoadContactsFromMask(hContact, mode, lparam)) {
				int i = GetInSessionOrder(hContact, mode, lparam);
				session_list_t[i] = hContact;
			}
		}
	int i = 0, j = 0;
	//TODO: change to "switch"
	while (session_list_t[i] != 0) {
		if (CheckForDuplicate(session_list, session_list_t[i]) == -1)
			CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)session_list_t[i], 0);
		else if (g_bWarnOnHidden) {
			if (!CheckContactVisibility(session_list_t[i])) {
				hidden[j] = i + 1;
				j++;
			}
			dup++;
		}
		i++;
	}

	if (i == 0) {
		if (g_bOtherWarnings)
			MessageBox(NULL, TranslateT("No contacts to open"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
		return 1;
	}

	if (dup == i) {
		if (!hidden[i]) {
			if (g_bOtherWarnings)
				MessageBox(NULL, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
			return 1;
		}
		if (!g_bWarnOnHidden && g_bOtherWarnings) {
			MessageBox(NULL, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
			return 1;
		}
		if (g_bWarnOnHidden) {
			if (IDYES == MessageBox(NULL, TranslateT("This Session already opened (but probably hidden).\nDo you want to show hidden contacts?"), TranslateT("Sessions Manager"), MB_YESNO | MB_ICONQUESTION))
				for (j = 0; hidden[j] != 0; j++)
					CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)session_list_t[hidden[j] - 1], 0);
		}
	}

	return 0;
}
Exemplo n.º 2
0
int OpLoadSessionContacts(WPARAM wparam,LPARAM lparam)
{
	ZeroMemory(session_list_t, sizeof(session_list_t));

	for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		if (LoadContactsFromMask(hContact,1,lparam)) {
			int i = GetInSessionOrder(hContact,1, lparam);
			session_list_t[i] = hContact;
		}
	}

	int i;
	for (i=0; session_list_t[i] != 0; i++)
		SendDlgItemMessage(g_opHdlg, IDC_OPCLIST, LB_ADDSTRING, 0, CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)session_list_t[i], GCDNF_TCHAR));

	return i;
}