int TSendContactsData::SendContactsPacket(HWND hwndDlg, HANDLE *phContacts, int nContacts) { HANDLE hProcc = (HANDLE)CallContactService(hContact, PSS_CONTACTS, MAKEWPARAM(0, nContacts), (LPARAM)phContacts); if (!hProcc) { // on trivial error - do not close dialog ShowErrorDlg(hwndDlg, "Contacts transfer failed!", FALSE); return FALSE; // Failure } TAckData *ackData = gaAckData.Add(hProcc, new TAckData(hContact)); uacklist.Add(hProcc); ackData->nContacts = nContacts; ackData->aContacts = (HANDLE*)mir_alloc(nContacts*sizeof(HANDLE)); memmove(ackData->aContacts, phContacts, nContacts*sizeof(HANDLE)); // copy the array of hContact for ack array EnableDlgItem(hwndDlg, IDOK, FALSE); EnableDlgItem(hwndDlg, IDC_LIST, FALSE); return TRUE; // Success }
int TSendContactsData::SendContacts(HWND hwndDlg) { char *szProto = GetContactProto(hContact); int nMaxContacts = CallProtoService(szProto, PS_GETCAPS, PFLAG_MAXCONTACTSPERPACKET, (LPARAM)hContact); if (!nMaxContacts) { ShowErrorDlg(hwndDlg, "The selected contact does not support receiving contacts.", FALSE); return FALSE; } // hook event - we want to receive protocol acknowledgements HookProtoAck(hwndDlg); // send in packets, each of nMaxContacts contacts for (int j = 0; j < nContacts / nMaxContacts; j++) if (!SendContactsPacket(hwndDlg, aContacts + j*nMaxContacts, nMaxContacts)) return FALSE; if (nContacts%nMaxContacts != 0) if (!SendContactsPacket(hwndDlg, aContacts + nContacts / nMaxContacts*nMaxContacts, nContacts%nMaxContacts)) return FALSE; return TRUE; }
void CScores::OnRequestFailedUser(SC_Error_t error) { FinishWait(); ShowErrorDlg("Connection error"); }