void SkypeFunctions::showContactList(wxListCtrl *contactList){ contactList->DeleteAllItems(); MyContactGroup::Ref skypeNamesContactGroup; if (!skype->GetHardwiredContactGroup(ContactGroup::ONLINE_BUDDIES, skypeNamesContactGroup)) throw SkypeException("Can't obtain contacts. (GetHardwiredContactGroup)\n"); if (!skypeNamesContactGroup->GetContacts(skypeNamesContactGroup->contactList)) throw SkypeException("Can't obtain contacts. (GetContacts)\n"); fetch(skypeNamesContactGroup->contactList); for (uint i = 0; i < skypeNamesContactGroup->contactList.size(); i++) { SEString id; if (!skypeNamesContactGroup->contactList[i]->GetIdentity(id)) throw SkypeException("Can't obatin contact id.\n"); SEString contactName; if (!skypeNamesContactGroup->contactList[i]->GetPropDisplayname(contactName)) throw SkypeException("Can't obtain contact name.\n"); SEString statusAsText; Contact::AVAILABILITY availability; if (!skypeNamesContactGroup->contactList[i]->GetPropAvailability(availability)) throw SkypeException("Cant obtain contact availability.\n"); statusAsText = tostring(availability); std::string auxS = (const char*) contactName; std::string auxS2 = (const char*) statusAsText; std::string auxS3 = (const char*) id; std::string status = "Contact::AVAILABILITY."; auxS2 = auxS2.substr(status.size(), auxS2.size()); wxString auxWXS(auxS.c_str(), wxConvUTF8); wxString auxWXS2(auxS2.c_str(), wxConvUTF8); wxString auxWXS3(auxS3.c_str(), wxConvUTF8); long itemIndex = contactList->InsertItem(0, auxWXS3); contactList->SetItem(itemIndex, 1, auxWXS2); contactList->SetItem(itemIndex, 2, auxWXS); }; }
int main(int argc, char * argv[]) { printf("*****************************************************************\n"); printf(" SkypeKit Tutorial, Step 4. - Contacts and online status events.\n"); printf("*****************************************************************\n"); if (argc < 3) { printf("usage: tutorial_4 <skypename> <password>\n"); return 0; }; myAccountName = argv[1]; myAccountPsw = argv[2]; printf("Creating skype ..\n"); skype = new MySkype(); printf("Submitting application token..\n"); getKeyPair (); skype->init(keyBuf, inetAddr, portNum, "streamlog.txt"); skype->start(); printf("Retrieving account ..\n"); MyAccount::Ref account; if (skype->GetAccount(myAccountName, account)) { printf("Logging in..\n"); account->LoginWithPassword(myAccountPsw, false, true); account->BlockWhileLoggingIn(); if (account->loggedIn) { printf("Loggin complete.\n"); MyContactGroup::Ref skypeNamesContactGroup; skype->GetHardwiredContactGroup(ContactGroup::SKYPE_BUDDIES, skypeNamesContactGroup); skypeNamesContactGroup->GetContacts(skypeNamesContactGroup->contactList); fetch(skypeNamesContactGroup->contactList); for (uint i = 0; i < skypeNamesContactGroup->contactList.size(); i++) { SEString contactName; skypeNamesContactGroup->contactList[i]->GetPropDisplayname(contactName); printf("%3d. %s\n", i+1, (const char*)contactName); }; printf("Waiting for contact status change events..\n"); printf("Press ENTER to quit.\n"); getchar(); printf("Logging out..\n"); account->Logout(false); account->BlockWhileLoggingOut(); printf("Logout complete.\n"); }; } else { printf("Account does not exist\n"); }; printf("Cleaning up.\n"); skype->stop(); delete skype; printf("Done.\n"); return 0; };
int SkypeFunctions::connect(wxListCtrl *contactList){ printf("[SKYPE]: Getting account...\n"); if (skype->GetAccount(accountName.c_str(), account)) { printf("[SKYPE]: Logging in...\n"); account->LoginWithPassword(accountPsw.c_str(), false, false); // Loop until LoggedIn or login failure during 3 seconds int sec = 0; while ( (!account->loggedIn) && (!account->loggedOut) && sec<3 ) { Delay(1); sec++; }; if (account->loggedIn) { //log->AppendText(wxString("Connected to Skype.\n", wxConvUTF8)); //initChat(); MyContactGroup::Ref skypeNamesContactGroup; if (!skype->GetHardwiredContactGroup(ContactGroup::ONLINE_BUDDIES, skypeNamesContactGroup)) throw SkypeException("Can't obtain contacts. (GetHardwiredContactGroup)\n"); if (!skypeNamesContactGroup->GetContacts(skypeNamesContactGroup->contactList)) throw SkypeException("Can't obtain contacts. (GetContacts)\n"); fetch(skypeNamesContactGroup->contactList); for (uint i = 0; i < skypeNamesContactGroup->contactList.size(); i++) { SEString id; if (!skypeNamesContactGroup->contactList[i]->GetIdentity(id)) throw SkypeException("Can't obatin contact id.\n"); SEString contactName; if (!skypeNamesContactGroup->contactList[i]->GetPropDisplayname(contactName)) throw SkypeException("Can't obtain contact name.\n"); SEString statusAsText; Contact::AVAILABILITY availability; if (!skypeNamesContactGroup->contactList[i]->GetPropAvailability(availability)) throw SkypeException("Cant obtain contact availability.\n"); statusAsText = tostring(availability); std::string auxS = (const char*) contactName; std::string auxS2 = (const char*) statusAsText; std::string auxS3 = (const char*) id; std::string status = "Contact::AVAILABILITY."; auxS2 = auxS2.substr(status.size(), auxS2.size()); wxString auxWXS(auxS.c_str(), wxConvUTF8); wxString auxWXS2(auxS2.c_str(), wxConvUTF8); wxString auxWXS3(auxS3.c_str(), wxConvUTF8); long itemIndex = contactList->InsertItem(0, auxWXS3); contactList->SetItem(itemIndex, 1, auxWXS2); contactList->SetItem(itemIndex, 2, auxWXS); }; connected = true; //getchar(); return 1; } else if (account->loggedOut) return 0; else return 0; } else throw SkypeException("Can't obtain account.\n"); }