/** triggered when someone joins the conference */ void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo *user) { CSametimeProto* proto = getProtoFromMwConference(conf); proto->debugLog(_T("mwServiceConf_on_peer_joined() start")); MCONTACT hContact = proto->FindContactByUserId(user->user_id); if (!hContact) { mwIdBlock idb; idb.user = ((mwLoginInfo *)user)->user_id; idb.community = 0; mwSametimeList* user_list = mwSametimeList_new(); char* utfs = mir_utf8encodeT(TranslateT("None")); mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, utfs); mwSametimeUser* stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, &idb); hContact = proto->AddContact(stuser, (proto->options.add_contacts ? false : true)); mwSametimeList_free(user_list); mir_free(utfs); } ptrT tszConfId(mir_utf8decodeT(mwConference_getName(conf))); ptrT tszUserName(mir_utf8decodeT(user->user_name)); ptrT tszUserId(mir_utf8decodeT(user->login_id)); // add user GCDEST gcd = { proto->m_szModuleName }; gcd.ptszID = tszConfId; gcd.iType = GC_EVENT_JOIN; GCEVENT gce = { sizeof(gce), &gcd }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tszUserName; gce.ptszUID = tszUserId; gce.ptszStatus = _T("Normal"); gce.time = (DWORD)time(0); CallServiceSync(MS_GC_EVENT, 0, (LPARAM) &gce); mir_free(tszUserName); mir_free(tszUserId); mir_free(tszConfId); }
/** an incoming file transfer has been offered */ void mwFileTransfer_offered(mwFileTransfer* ft) { CSametimeProto* proto = getProtoFromMwFileTransfer(ft); proto->debugLog(_T("mwFileTransfer_offered() start")); const mwIdBlock* idb = mwFileTransfer_getUser(ft); MCONTACT hContact = proto->FindContactByUserId(idb->user); proto->debugLog(_T("Sametime mwFileTransfer_offered hContact=[%x]"), hContact); if (!hContact) { mwSametimeList* user_list = mwSametimeList_new(); mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, Translate("None")); mwSametimeUser* stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, (mwIdBlock*)idb); hContact = proto->AddContact(stuser, (proto->options.add_contacts ? false : true)); } proto->ProtoBroadcastAck(hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (HANDLE)ft, 0); TCHAR* filenameT = mir_utf8decodeT(mwFileTransfer_getFileName(ft)); const char* message = mwFileTransfer_getMessage(ft); TCHAR descriptionT[512]; if (message) { TCHAR* messageT = mir_utf8decodeT(message); mir_sntprintf(descriptionT, _T("%s - %s"), filenameT, messageT); mir_free(messageT); } else _tcsncpy_s(descriptionT, filenameT, _TRUNCATE); PROTORECVFILET pre = {0}; pre.dwFlags = PRFF_TCHAR; pre.fileCount = 1; pre.timestamp = time(NULL); pre.descr.t = descriptionT; pre.files.t = &filenameT; pre.lParam = (LPARAM)ft; ProtoChainRecvFile(hContact, &pre); mir_free(filenameT); }
void mwResolve_handler_dyngroup_callback(mwServiceResolve* srvc, guint32 id, guint32 code, GList *results, gpointer data) { CSametimeProto* proto = getProtoFromMwServiceResolve(srvc); mwSametimeGroup* stgroup = (mwSametimeGroup*)data; mwResolveResult* result; mwResolveMatch* match; g_return_if_fail(results != NULL); if (results) { result = (mwResolveResult*)results->data; if (result && result->matches) { match = (mwResolveMatch*)result->matches->data; if (match) { mwIdBlock uid; uid.user = match->id; uid.community = 0; mwSametimeUser *stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, &uid); mwSametimeUser_setShortName(stuser, match->name); MCONTACT hContact = proto->AddContact(stuser, false); const char* group_name = mwSametimeGroup_getName(stgroup); const char* group_alias = mwSametimeGroup_getAlias(stgroup); if (!group_alias) group_alias = group_name; if (hContact && group_alias && mir_strcmp(group_alias, Translate("None")) && mir_strcmp(group_alias, "MetaContacts Hidden Group")) { proto->SetContactGroup(hContact, group_alias); } } } } if (stgroup) mwSametimeList_free(mwSametimeGroup_getList(stgroup)); }