Esempio n. 1
0
int RegisterService(WPARAM wParam, LPARAM lParam)
{
	SPEAK_TYPE *orig = (SPEAK_TYPE *) wParam;
	if (orig == NULL || orig->cbSize < sizeof(SPEAK_TYPE) 
		|| orig->name == NULL || orig->description == NULL)
		return -1;

	SPEAK_TYPE *type = (SPEAK_TYPE *) mir_alloc0(sizeof(SPEAK_TYPE));
	type->cbSize = orig->cbSize;
	type->module = mir_strdup(orig->module);
	type->name = mir_strdup(orig->name);
	type->description = Translate(mir_strdup(orig->description));
	type->icon = mir_strdup(orig->icon);
	type->numTemplates = orig->numTemplates;

	if (orig->numTemplates > 0)
	{
		type->templates = (char **) mir_alloc0(orig->numTemplates * sizeof(char *));
		for(int i = 0; i < orig->numTemplates; i++)
			type->templates[i] = mir_strdup(orig->templates[i] == NULL ? "" : orig->templates[i]);
	}

	types.insert(type);

	return 0;
}
Esempio n. 2
0
void Protocol::SetStatus(int aStatus)
{
	char status_msg[256];

	if (ServiceExists(MS_CS_SETSTATUSEX))
	{
		// :'(

		// BEGIN From commomstatus.cpp (KeepStatus)
		int i, count, pCount;
		PROTOCOLDESCRIPTOR **protos;

		pCount = 0;
		CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&count,(LPARAM)&protos);
		for(i=0;i<count;i++) {
			if(protos[i]->type!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue;
			pCount += 1;
		}
		// END From commomstatus.cpp (KeepStatus)


		PROTOCOLSETTINGEX **pse = (PROTOCOLSETTINGEX **) mir_alloc0(pCount * sizeof(PROTOCOLSETTINGEX *));

		for(i = 0; i < pCount; i++)
		{
			pse[i] = (PROTOCOLSETTINGEX *) mir_alloc0(sizeof(PROTOCOLSETTINGEX));
			pse[i]->szName = "";
		}

		pse[0]->cbSize = sizeof(PROTOCOLSETTINGEX);
		pse[0]->status = aStatus;
		pse[0]->szName = (char *) name.c_str();

		GetStatusMsg(aStatus, status_msg, sizeof(status_msg));
		pse[0]->szMsg = status_msg;

		CallService(MS_CS_SETSTATUSEX, (WPARAM) &pse, 0);

		for(i = 0; i < pCount; i++)
			mir_free(pse[i]);
		mir_free(pse);
	}
	else
	{
		Call(PS_SETSTATUS, aStatus);

		if (CanSetStatusMsg(aStatus))
		{
			char status_msg[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE];
			GetStatusMsg(aStatus, status_msg, sizeof(status_msg));
			SetStatusMsg(aStatus, status_msg);
		}
	}
}
Esempio n. 3
0
HANDLE HistoryLog(HANDLE hContact, TCHAR *log_text)
{
	if (log_text != NULL)
	{
		DBEVENTINFO event = { 0 };
		BYTE *tmp = NULL;

		event.cbSize = sizeof(event);

#ifdef UNICODE

		size_t needed = WideCharToMultiByte(CP_ACP, 0, log_text, -1, NULL, 0, NULL, NULL);
		size_t len = lstrlen(log_text);
		size_t size;

		if (opts.history_only_ansi_if_possible && IsUnicodeAscii(log_text, len))
			size = needed;
		else
			size = needed + (len + 1) * sizeof(WCHAR);

		tmp = (BYTE *) mir_alloc0(size);

		WideCharToMultiByte(CP_ACP, 0, log_text, -1, (char *) tmp, needed, NULL, NULL);

		if (size > needed)
			lstrcpyn((WCHAR *) &tmp[needed], log_text, len + 1);

		event.pBlob = tmp;
		event.cbBlob = size;

#else

		event.pBlob = (PBYTE) log_text;
		event.cbBlob = strlen(log_text) + 1;

#endif

		event.eventType = EVENTTYPE_NICKNAME_CHANGE;
		event.flags = DBEF_READ;
		event.timestamp = (DWORD) time(NULL);

		event.szModule = MODULE_NAME;
		
		// Is a subcontact?
		if (ServiceExists(MS_MC_GETMETACONTACT)) 
		{
			HANDLE hMetaContact = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);

			if (hMetaContact != NULL && ContactEnabled(hMetaContact))
				CallService(MS_DB_EVENT_ADD,(WPARAM)hMetaContact,(LPARAM)&event);
		}

		HANDLE ret = (HANDLE) CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&event);

		mir_free(tmp);

		return ret;
	}
	else
	{
		return NULL;
	}
}