Пример #1
0
void Meta_Assign(HANDLE hSub, HANDLE hMeta) {
    metaMap[hMeta].add(hSub);
    DBWriteContactSettingDword(hSub, MODULE, "ParentMetaID", DBGetContactSettingDword(hMeta, MODULE, META_ID, -1));
    DBWriteContactSettingDword(hSub, MODULE, "Handle", (DWORD)hMeta);
    DBWriteContactSettingByte(hSub, MODULE, "IsSubcontact", 1);
    if(MetaEnabled()) {
        if(!meta_group_hack_disabled)
            DBWriteContactSettingByte(hSub, "CList", "Hidden", 1);
    } else // shouldn't happen, as the menu option is hidden when metas are disabled...
        DBWriteContactSettingByte(hMeta, "CList", "Hidden", 1);

    CallService(MS_IGNORE_IGNORE, (WPARAM)hSub, (WPARAM)IGNOREEVENT_USERONLINE);

    DBVARIANT dbv;
    if(DBGetContactSettingUTF8String(hMeta, "CList", "MyHandle", &dbv)) {
        if(!DBGetContactSettingUTF8String(hSub, "CList", "MyHandle", &dbv)) {
            DBWriteContactSettingUTF8String(hMeta, "CList", "MyHandle", dbv.pszVal);
            DBFreeVariant(&dbv);
        }
    } else
        DBFreeVariant(&dbv);

    if(DBGetContactSettingUTF8String(hMeta, MODULE, "Nick", &dbv)) {
        char *subProto = ContactProto(hSub);
        if(subProto) {
            if(!DBGetContactSettingUTF8String(hSub, subProto, "Nick", &dbv)) {
                DBWriteContactSettingUTF8String(hMeta, MODULE, "Nick", dbv.pszVal);
                DBFreeVariant(&dbv);
            }
        }
    } else
        DBFreeVariant(&dbv);

    FireSubcontactsChanged(hMeta);
}
Пример #2
0
/** Scans the \c CHANGES and call the appropriate function for each change.
*
* @param chg : Structure holding all the change info (See CHANGES).
*/
void ApplyChanges(CHANGES *chg)
{
	HANDLE most_online;
	int i;

	// remove removed contacts
	for(i = 0; i < chg->num_deleted; i++) {
		Meta_Delete((WPARAM)chg->hDeletedContacts[i], 0);
		if(chg->hDeletedContacts[i] == chg->hDefaultContact)
			chg->hDefaultContact = 0;
		if(chg->hDeletedContacts[i] == chg->hOfflineContact)
			chg->hOfflineContact = 0;
	}

	// set contact positions
	for(i = 0; i < chg->num_contacts; i++) {
		if(Meta_GetContactNumber(chg->hContact[i]) != i)
			Meta_SwapContacts(chg->hMeta, Meta_GetContactNumber(chg->hContact[i]), i);
	}

	NotifyEventHooks(hSubcontactsChanged, (WPARAM)chg->hMeta, (LPARAM)chg->hDefaultContact);

	// set default
	if(chg->hDefaultContact)
		DBWriteContactSettingDword(chg->hMeta, META_PROTO, "Default", Meta_GetContactNumber(chg->hDefaultContact));
	else
		DBWriteContactSettingDword(chg->hMeta, META_PROTO, "Default", 0);
	NotifyEventHooks(hEventDefaultChanged, (WPARAM)chg->hMeta, (LPARAM)chg->hDefaultContact);

	// set offline
	if(chg->hOfflineContact)
		DBWriteContactSettingDword(chg->hMeta, META_PROTO, "OfflineSend", Meta_GetContactNumber(chg->hOfflineContact));
	else
		DBWriteContactSettingDword(chg->hMeta, META_PROTO, "OfflineSend", (DWORD)-1);

	// fix nick
	most_online = Meta_GetMostOnline(chg->hMeta);
	Meta_CopyContactNick(chg->hMeta, most_online);

	// fix status
	Meta_FixStatus(chg->hMeta);

	// fix avatar
	most_online = Meta_GetMostOnlineSupporting(chg->hMeta, PFLAGNUM_4, PF4_AVATARS);
	if(most_online) {
		PROTO_AVATAR_INFORMATION AI;

		AI.cbSize = sizeof(AI);
		AI.hContact = chg->hMeta;
		AI.format = PA_FORMAT_UNKNOWN;
		strcpy(AI.filename, "X");

		if((int)CallProtoService(META_PROTO, PS_GETAVATARINFO, 0, (LPARAM)&AI) == GAIR_SUCCESS)
	        DBWriteContactSettingString(chg->hMeta, "ContactPhoto", "File",AI.filename);
	}

	if(MetaAPI_GetForceState((WPARAM)chg->hMeta, 0) != chg->force_default)
		MetaAPI_ForceDefault((WPARAM)chg->hMeta, 0);
}
Пример #3
0
void SavePosition(HWND hwnd, char *wndName)
{
	RECT rc;
	char buffer[512];
	GetWindowRect(hwnd, &rc);
	mir_snprintf(buffer, SIZEOF(buffer), "%sPosX", wndName);
	DBWriteContactSettingDword(0, __INTERNAL_NAME, buffer, rc.left);
	mir_snprintf(buffer, SIZEOF(buffer), "%sPosY", wndName);
	DBWriteContactSettingDword(0, __INTERNAL_NAME, buffer, rc.top);
}
Пример #4
0
/** Convert the contact chosen into a MetaContact.
*
* Create a new MetaContact, remove the selected contact from the \c CList
* and attach it to the MetaContact.
*
* @param wParam :	\c HANDLE to the contact that has been chosen.
* @param lParam :	Allways set to 0.
*/
INT_PTR Meta_Convert(WPARAM wParam,LPARAM lParam)
{
	HANDLE hMetaContact;
	DBVARIANT dbv;
	char *group = 0;//, *proto;
		
	// Get some information about the selected contact.
//	proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0);
	if(!DBGetContactSettingStringUtf((HANDLE)wParam,"CList","Group",&dbv)) {
		group = _strdup(dbv.pszVal);
		DBFreeVariant(&dbv);
	}

	// Create a new metacontact
	hMetaContact = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0);
			
	// Add the info for the metacontact
	if(hMetaContact)
	{

		DBWriteContactSettingDword(hMetaContact,META_PROTO,META_ID,nextMetaID);
		DBWriteContactSettingDword(hMetaContact,META_PROTO,"NumContacts",0);
		DBWriteContactSettingDword(NULL,META_PROTO,"NextMetaID",++nextMetaID);

		// Add the MetaContact protocol to the new meta contact
		CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )hMetaContact, ( LPARAM )META_PROTO );

		if(group) {
			if(ServiceExists(MS_DB_CONTACT_GETSETTING_STR))
				DBWriteContactSettingStringUtf(hMetaContact,"CList","Group",group);
			else
				DBWriteContactSettingString(hMetaContact,"CList","Group",group);
		}
		
		// Assign the contact to the MetaContact just created (and make default).
		if(!Meta_Assign((HANDLE)wParam,hMetaContact,TRUE)) {
			MessageBox(0,Translate("There was a problem in assigning the contact to the MetaContact"),Translate("Error"),MB_ICONEXCLAMATION);
			CallService(MS_DB_CONTACT_DELETE, (WPARAM)hMetaContact, 0);
			return 0;
		}

		// hide the contact if clist groups disabled (shouldn't create one anyway since menus disabled)
		if(!Meta_IsEnabled())
			DBWriteContactSettingByte(hMetaContact, "CList", "Hidden", 1);

	}

	//	Update the graphics
	CallService(MS_CLUI_SORTLIST,0,0);

	free(group);
	return (int)hMetaContact;
}
Пример #5
0
void SaveOptions() {
	DBWriteContactSettingDword(0, MODULE, "DefaultTimeout", options.default_timeout);
	DBWriteContactSettingDword(0, MODULE, "WinWidth", options.win_width);
	DBWriteContactSettingDword(0, MODULE, "WinMaxHeight", options.win_max_height);
	DBWriteContactSettingByte(0, MODULE, "Location", (BYTE)options.location);
	DBWriteContactSettingByte(0, MODULE, "Opacity", (BYTE)options.opacity);
	DBWriteContactSettingByte(0, MODULE, "Border", (options.border ? 1 : 0));
	DBWriteContactSettingByte(0, MODULE, "RoundCorners", (options.round ? 1 : 0));
	DBWriteContactSettingByte(0, MODULE, "AvatarRoundCorners", (options.av_round ? 1 : 0));
	DBWriteContactSettingByte(0, MODULE, "Animate", (options.animate ? 1 : 0));
	DBWriteContactSettingByte(0, MODULE, "TransparentBg", (options.trans_bg ? 1 : 0));
	DBWriteContactSettingByte(0, MODULE, "UseMimMonitor", (options.use_mim_monitor ? 1 : 0));
	DBWriteContactSettingByte(0, MODULE, "RightIcon", (options.right_icon ? 1 : 0));
	if(ServiceExists(MS_AV_DRAWAVATAR))
		DBWriteContactSettingByte(0, MODULE, "AVLayout", (BYTE)options.av_layout);
	DBWriteContactSettingDword(0, MODULE, "AVSize", options.av_size);
	DBWriteContactSettingDword(0, MODULE, "TextIndent", options.text_indent);
	DBWriteContactSettingByte(0, MODULE, "GlobalHover", (options.global_hover ? 1 : 0));
	DBWriteContactSettingByte(0, MODULE, "TimeLayout", (BYTE)options.time_layout);

	char buff[128];
	for(int i = 0; i < 9; i++) {
		sprintf(buff, "DisableStatus%d", i - 1);
		DBWriteContactSettingByte(0, MODULE, buff, options.disable_status[i] ? 1 : 0);
	}
	DBWriteContactSettingByte(0, MODULE, "DisableFullScreen", (options.disable_full_screen ? 1 : 0));
	DBWriteContactSettingByte(0, MODULE, "DropShadow", (options.drop_shadow ? 1 : 0));
	DBWriteContactSettingDword(0, MODULE, "SidebarWidth", options.sb_width);
	DBWriteContactSettingDword(0, MODULE, "Padding", options.padding);
	DBWriteContactSettingDword(0, MODULE, "AvatarPadding", options.av_padding);
}
Пример #6
0
int ModulesLoaded(WPARAM wParam, LPARAM lParam) 
{
	InitFonts();
	InitUpdaterSupport();

	hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged);
	hShowTipEvent = HookEvent(ME_CLC_SHOWINFOTIP, ShowTipHook);
	hHideTipEvent = HookEvent(ME_CLC_HIDEINFOTIP, HideTipHook);
	hAckEvent = HookEvent(ME_PROTO_ACK, ProtoAck);

	hFramesSBShow = HookEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP, FramesShowSBTip);
	hFramesSBHide = HookEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP, FramesHideSBTip);

	hFolderChanged = HookEvent(ME_FOLDERS_PATH_CHANGED, ReloadSkinFolder);

	hSkinFolder = FoldersRegisterCustomPathT(MODULE, "Tipper skins", MIRANDA_PATHT _T("\\") _T(DEFAULT_SKIN_FOLDER));
	FoldersGetCustomPathT(hSkinFolder, SKIN_FOLDER, SIZEOF(SKIN_FOLDER), _T(DEFAULT_SKIN_FOLDER));

	InitTipperSmileys();
	LoadOptions(); 
	ReloadFont(0, 0);
	ParseSkinFile(opt.szSkinName, true, false);

	// set 'time-in'
	CallService(MS_CLC_SETINFOTIPHOVERTIME, opt.iTimeIn, 0);

	// set Miranda start timestamp
	DBWriteContactSettingDword(0, MODULE, "MirandaStartTS", (DWORD)time(0));

	// get MetaContacts module name
	if (ServiceExists(MS_MC_GETPROTOCOLNAME))
		strcpy(szMetaModuleName, (char *)CallService(MS_MC_GETPROTOCOLNAME, 0, 0));

	return 0;
}
Пример #7
0
void write_ping_address(PINGADDRESS *i) {
	bool is_contact = (bool)(CallService(MS_DB_CONTACT_IS, (WPARAM)i->hContact, 0) != 0);

	if(!is_contact) {
		//MessageBox(0, "Creating contact", "Ping", MB_OK);
		i->hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
		CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )i->hContact, ( LPARAM )PROTO );	
		CallService(MS_IGNORE_IGNORE, (WPARAM)i->hContact, (WPARAM)IGNOREEVENT_USERONLINE);
	}
	DBWriteContactSettingString(i->hContact, PROTO, "Address", i->pszName);
	set_changing_clist_handle(TRUE);
	DBWriteContactSettingString(i->hContact, "CList", "MyHandle", i->pszLabel);
	set_changing_clist_handle(FALSE);
	DBWriteContactSettingString(i->hContact, PROTO, "Nick", i->pszLabel);
	DBWriteContactSettingWord(i->hContact, PROTO, "Status", i->status);
	DBWriteContactSettingDword(i->hContact, PROTO, "Port", i->port);
	DBWriteContactSettingString(i->hContact, PROTO, "Proto", i->pszProto);
	if(strlen(i->pszCommand))
		DBWriteContactSettingString(i->hContact, PROTO, "Command", i->pszCommand);
	else
		DBDeleteContactSetting(i->hContact, PROTO, "Command");
	if(strlen(i->pszParams))
		DBWriteContactSettingString(i->hContact, PROTO, "CommandParams", i->pszParams);
	else
		DBDeleteContactSetting(i->hContact, PROTO, "CommandParams");
	DBWriteContactSettingWord(i->hContact, PROTO, "SetStatus", i->set_status);
	DBWriteContactSettingWord(i->hContact, PROTO, "GetStatus", i->get_status);
	DBWriteContactSettingWord(i->hContact, PROTO, "Index", i->index);
	if(strlen(i->pszCListGroup))
		DBWriteContactSettingString(i->hContact, "CList", "Group", i->pszCListGroup);
	else
		DBDeleteContactSetting(i->hContact, "CList", "Group");
}
void MirandaSkinnedDialog::setSettting(const char *name, int val, bool global)
{
	char setting[SETTING_NAME_SIZE];
	getSettingName(setting, name, global);

	DBWriteContactSettingDword(NULL, getModule(), setting, val);
}
Пример #9
0
int FacebookProto::RemoveFriend(WPARAM wParam,LPARAM lParam)
{
	if (wParam == NULL)
	{ // self contact
	//	CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(FACEBOOK_URL_PROFILE));
		return 0;
	}
	
	if (isOffline())
		return 0;

	if (MessageBox( 0, TranslateT("Are you sure?"), TranslateT("Delete contact from server list"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2 ) != IDYES)
		return 0;

	HANDLE hContact = reinterpret_cast<HANDLE>(wParam);

	DBVARIANT dbv;			
	if( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) )
	{
		if (!isOffline()) {
			std::string* id = new std::string(dbv.pszVal);
			ForkThread( &FacebookProto::DeleteContactFromServer, this, ( void* )id );
			DBFreeVariant(&dbv);

			if ( !DBGetContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, 0) )
				DBWriteContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, ::time(NULL));
		}
	}

	return 0;
}
Пример #10
0
static void addWindow(HANDLE hContact) 
{
	CLISTFrame Frame = {0};
	HWND hWnd;
	DBVARIANT dbv;
	char winname[512];
	DWORD frameID;

	DBGetContactSettingString(hContact, WEATHERPROTONAME, "Nick", &dbv);
	mir_snprintf(winname, sizeof(winname), "Weather: %s", dbv.pszVal);
	DBFreeVariant(&dbv);

	hWnd = CreateWindow("WeatherFrame", "", WS_CHILD | WS_VISIBLE, 
		0, 0, 10, 10, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL, hInst, hContact);

	Frame.name = winname;
	Frame.cbSize = sizeof(Frame);
	Frame.hWnd = hWnd;
	Frame.align = alBottom;
	Frame.Flags = F_VISIBLE|F_NOBORDER;
	Frame.height = 32;

	WindowList_Add(hMwinWindowList, hWnd, hContact);

	frameID = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0);
	DBWriteContactSettingDword(hContact, WEATHERPROTONAME, "mwin", frameID);
	DBWriteContactSettingByte(hContact, "CList", "Hidden", TRUE);
}
Пример #11
0
static BOOL Convert(HANDLE hContact, char* module, char* setting, int value, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string
{
    int Result = 1;
	char temp[64];

	switch (toType)
	{
		case 0:
			if (value > 0xFF)
				Result = 0;
			else
				DBWriteContactSettingByte(hContact, module, setting, (BYTE)value);
		break;
		case 1:
			if (value > 0xFFFF)
				Result = 0;
			else
				DBWriteContactSettingWord(hContact, module, setting, (WORD)value);
		break;
		case 2:
			DBWriteContactSettingDword(hContact, module, setting, (DWORD)value);
		break;
		case 3:
			DBDeleteContactSetting(hContact, module, setting);
			DBWriteContactSettingString(hContact, module, setting, itoa(value,temp,10));
		break;
	}
	return Result;
}
Пример #12
0
void UpgradeCheck(void)
{
    DWORD dwVersion = DBGetContactSettingDword(NULL, "Chat", "OldVersion", PLUGIN_MAKE_VERSION(0,2,9,9));
    if (	pluginInfo.version > dwVersion)
    {
        if (dwVersion < PLUGIN_MAKE_VERSION(0,3,0,0))
        {
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font18");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font18Col");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font18Set");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font18Size");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font18Sty");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font19");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font19Col");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font19Set");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font19Size");
            DBDeleteContactSetting(NULL, "ChatFonts",	"Font19Sty");
            DBDeleteContactSetting(NULL, "Chat",		"ColorNicklistLines");
            DBDeleteContactSetting(NULL, "Chat",		"NicklistIndent");
            DBDeleteContactSetting(NULL, "Chat",		"NicklistRowDist");
            DBDeleteContactSetting(NULL, "Chat",		"ShowFormatButtons");
            DBDeleteContactSetting(NULL, "Chat",		"ShowLines");
            DBDeleteContactSetting(NULL, "Chat",		"ShowName");
            DBDeleteContactSetting(NULL, "Chat",		"ShowTopButtons");
            DBDeleteContactSetting(NULL, "Chat",		"SplitterX");
            DBDeleteContactSetting(NULL, "Chat",		"SplitterY");
            DBDeleteContactSetting(NULL, "Chat",		"IconFlags");
            DBDeleteContactSetting(NULL, "Chat",		"LogIndentEnabled");
        }
    }

    DBWriteContactSettingDword(NULL, "Chat", "OldVersion", pluginInfo.version);
}
Пример #13
0
static int SaveTree(HWND hwndDlg)
{
	TVITEM tvi;
	int count;
	TCHAR idstr[100];
	char menuItemName[256], DBString[256], MenuNameItems[256];
	int menupos;
	int MenuObjectId, runtimepos;
	TIntMenuObject* pimo;
	MenuItemOptData* iod;
	HWND hTree = GetDlgItem( hwndDlg, IDC_MENUITEMS );

	if ( !GetCurrentMenuObjectID( hwndDlg, &MenuObjectId ))
		return 0;

	tvi.hItem = TreeView_GetRoot( hTree );
	tvi.cchTextMax = 99;
	tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
	tvi.pszText = idstr;
	count = 0;

	menupos = GetMenuObjbyId( MenuObjectId );
	if ( menupos == -1 )
		return -1;

	pimo = g_menus[menupos];

	mir_snprintf( MenuNameItems, sizeof(MenuNameItems), "%s_Items", pimo->Name);
	runtimepos = 100;

	while ( tvi.hItem != NULL ) {
		TreeView_GetItem( hTree, &tvi );
		iod = ( MenuItemOptData* )tvi.lParam;
		if ( iod->pimi ) {
			GetMenuItemName( iod->pimi, menuItemName, sizeof( menuItemName ));

			mir_snprintf( DBString, SIZEOF(DBString), "%s_visible", menuItemName );
			DBWriteContactSettingByte( NULL, MenuNameItems, DBString, iod->show );

			mir_snprintf( DBString, SIZEOF(DBString), "%s_pos", menuItemName );
			DBWriteContactSettingDword( NULL, MenuNameItems, DBString, runtimepos );

			mir_snprintf( DBString, SIZEOF(DBString), "%s_name", menuItemName );
			if ( lstrcmp( iod->name, iod->defname ) != 0 )
				DBWriteContactSettingTString( NULL, MenuNameItems, DBString, iod->name );
			else
				DBDeleteContactSetting( NULL, MenuNameItems, DBString );

			runtimepos += 100;
		}

		if ( iod->name && !_tcscmp( iod->name, STR_SEPARATOR) && iod->show )
			runtimepos += SEPARATORPOSITIONINTERVAL;

		tvi.hItem = TreeView_GetNextSibling( hTree, tvi.hItem );
		count++;
	}
	return 1;
}
Пример #14
0
static INT_PTR Unignore(WPARAM wParam,LPARAM lParam)
{
	DWORD mask=GetMask((HANDLE)wParam);
	if((lParam<1 || lParam>IGNOREEVENT_MAX) && lParam!=IGNOREEVENT_ALL) return 1;
	if(lParam==IGNOREEVENT_ALL) mask=0;
	else mask&=~(1<<(lParam-1));
	DBWriteContactSettingDword((HANDLE)wParam,"Ignore","Mask1",mask);
	return 0;
}
Пример #15
0
static int sttSaveAvatar()
{
	FILE* in;
	SHA1Context sha;
//	MD5Context md5;
	unsigned char buf[ 512 ];
	char tFileName[ MAX_PATH ];
	int i, pictureType;
	int bIsFirst = 1;
	struct _stat statbuf;
	uint8_t digest[20];

	if (_stat(szFileName, &statbuf)) return 1;
	if (statbuf.st_size > 6 * 1024) return 1;
	
	TlenGetAvatarFileName( NULL, tFileName, sizeof tFileName );
	if ( CopyFileA( szFileName, tFileName, FALSE ) == FALSE ) {
		JabberLog( "Copy failed with error %d", GetLastError() );
		return 1;
	}
	SHA1Reset(&sha);
//	md5_init(&md5);
	in = fopen( tFileName, "rb" );
	if ( in == NULL )
		return 1;

	while( !feof( in )) {
		int bytes = fread( buf, 1, sizeof buf, in );
		if ( bIsFirst ) {
			pictureType = JabberGetPictureType( buf );
			bIsFirst = 0;
		}
		SHA1Input(&sha, buf, bytes);
//		md5_update(&md5, buf, bytes);
	}
	fclose( in );
	if ( pictureType == PA_FORMAT_UNKNOWN )
		return 1;
	SHA1Result(&sha, digest);
//	md5_finalize(&md5);
	for (i=0;i<20;i++) {
//		unsigned int val = (md5.state[i>>2] >> 8*(i%4)) & 0xFF;
		sprintf( buf+( i<<1 ), "%02x", digest[i]);
	}
	DBWriteContactSettingString(NULL, jabberProtoName, "AvatarHash", buf);
	DBWriteContactSettingDword(NULL, jabberProtoName, "AvatarFormat", pictureType);
	if (userAvatarHash != NULL) {
		free (userAvatarHash);
		userAvatarHash = NULL;
	}
	userAvatarHash = strdup(buf);
	userAvatarFormat = pictureType;
	TlenGetAvatarFileName(NULL, szFileName, MAX_PATH);
	if ( strcmp( szFileName, tFileName ))
		MoveFileA( tFileName, szFileName );
	return 0;
}
Пример #16
0
void removeWindow(HANDLE hContact) 
{
	DWORD frameId = DBGetContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0);

	WindowList_Remove(hMwinWindowList, WindowList_Find(hMwinWindowList, hContact));
	CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0);

	DBWriteContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0);
	DBDeleteContactSetting(hContact, "CList", "Hidden");
}
Пример #17
0
/** Set contact as MetaContact default
*
* Set the given contact to be the default one for the metacontact to which it is linked.
*
* @param wParam :	\c HANDLE to the MetaContact to be set as default
* @param lParam :	\c HWND to the clist window
					(This means the function has been called via the contact menu).
*/
INT_PTR Meta_Default(WPARAM wParam,LPARAM lParam)
{
	HANDLE hMeta;

	if((hMeta = (HANDLE)DBGetContactSettingDword((HANDLE)wParam,META_PROTO,"Handle",0)) != 0)
	{ // the wParam is a subcontact
		DBWriteContactSettingDword(hMeta, META_PROTO, "Default", (DWORD)Meta_GetContactNumber((HANDLE)wParam));
		NotifyEventHooks(hEventDefaultChanged, (WPARAM)hMeta, (LPARAM)(HANDLE)wParam);
	}
	return 0;
}
Пример #18
0
void save_listbox_items() {
	DBWriteContactSettingDword(0, "WorldTime", "NumEntries", listbox_items.getCount());
	int index = 0;
	for(int i = 0; i < listbox_items.getCount(); i++, index++) {
		char p1[20], p2[20], p3[20], p4[20], p5[20];

		mir_snprintf(p1, SIZEOF(p1), "Label%d", i);
		mir_snprintf(p2, SIZEOF(p2), "Index%d", i);
		mir_snprintf(p3, SIZEOF(p3), "Sunrise%d", i);
		mir_snprintf(p4, SIZEOF(p4), "Sunset%d", i);
		mir_snprintf(p5, SIZEOF(p5), "TZName%d", i);

		DBWriteContactSettingTString(0, "WorldTime", p1, listbox_items[i].pszText);
		DBWriteContactSettingDword(0, "WorldTime", p2, listbox_items[i].timezone_list_index);
		DBWriteContactSettingDword(0, "WorldTime", p3, listbox_items[i].sunrise.wHour * 60 + listbox_items[i].sunrise.wMinute);
		DBWriteContactSettingDword(0, "WorldTime", p4, listbox_items[i].sunset.wHour * 60 + listbox_items[i].sunset.wMinute);
		DBWriteContactSettingTString(0, "WorldTime", p5, timezone_list[listbox_items[i].timezone_list_index].tcName);
	}
	DBWriteContactSettingWord(0, "WorldTime", "DataVersion", 1);
}
Пример #19
0
static void SaveItemMask(HWND hwndList,HANDLE hContact,HANDLE hItem,const char *pszSetting)
{
	DWORD mask;
	int i,iImage;

	mask=0;
	for(i=0;i<IGNOREEVENT_MAX;i++) {
		iImage=SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(i,0));
		if(iImage && iImage!=0xFF) mask|=1<<i;
	}
	DBWriteContactSettingDword(hContact,"Ignore",pszSetting,mask);
}
Пример #20
0
void SaveOptions() {
	DBWriteContactSettingDword(NULL, PLUG, "PingPeriod", options.ping_period);
	DBWriteContactSettingDword(NULL, PLUG, "PingTimeout", options.ping_timeout);
	CallService(PLUG "/SetPingTimeout", (WPARAM)options.ping_timeout, 0);
	DBWriteContactSettingByte(NULL, PLUG, "ShowPopup", options.show_popup ? 1 : 0);
	DBWriteContactSettingByte(NULL, PLUG, "ShowPopup2", options.show_popup2 ? 1 : 0);
	DBWriteContactSettingByte(NULL, PLUG, "BlockReps", options.block_reps ? 1 : 0);
	DBWriteContactSettingByte(NULL, PLUG, "LoggingEnabled", options.logging ? 1 : 0);

	DBWriteContactSettingByte(NULL, PLUG, "NoTestStatus", options.no_test_icon ? 1 : 0);

	DBWriteContactSettingWord(NULL, PLUG, "Indent", options.indent);
	DBWriteContactSettingWord(NULL, PLUG, "RowHeight", options.row_height);

	DBWriteContactSettingDword(NULL, PLUG, "Retries", (DWORD)options.retries);

	CallService(PLUG "/SetLogFilename", (WPARAM)MAX_PATH, (LPARAM)options.log_filename);

	ICMP::get_instance()->set_timeout(options.ping_timeout * 1000);

	DBWriteContactSettingByte(NULL, PLUG, "AttachToClist", options.attach_to_clist ? 1 : 0);
	DBWriteContactSettingByte(NULL, PLUG, "LogCSV", options.log_csv ? 1 : 0);
}
Пример #21
0
int __declspec(dllexport) Unload(void)
{
    DBWriteContactSettingWord(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
    DBWriteContactSettingWord(NULL, "Chat", "SplitterY", (WORD)g_Settings.iSplitterY);
    DBWriteContactSettingDword(NULL, "Chat", "roomx", g_Settings.iX);
    DBWriteContactSettingDword(NULL, "Chat", "roomy", g_Settings.iY);
    DBWriteContactSettingDword(NULL, "Chat", "roomwidth" , g_Settings.iWidth);
    DBWriteContactSettingDword(NULL, "Chat", "roomheight", g_Settings.iHeight);

    CList_SetAllOffline(TRUE, NULL);

    mir_free( pszActiveWndID );
    mir_free( pszActiveWndModule );

    DestroyMenu(g_hMenu);
    DestroyServiceFunctions();
    DestroyHookableEvents();
    FreeIcons();
    OptionsUnInit();
    FreeLibrary(GetModuleHandleA("riched20.dll"));
    UnhookEvents();
    return 0;
}
Пример #22
0
void SaveOptions() {
	DBWriteContactSettingDword(NULL, PROTO, "PingPeriod", options.ping_period);
	DBWriteContactSettingDword(NULL, PROTO, "PingTimeout", options.ping_timeout);
	//CallService(PROTO "/SetPingTimeout", (WPARAM)options.ping_timeout, 0);
	DBWriteContactSettingByte(NULL, PROTO, "ShowPopup", options.show_popup ? 1 : 0);
	DBWriteContactSettingByte(NULL, PROTO, "ShowPopup2", options.show_popup2 ? 1 : 0);
	DBWriteContactSettingByte(NULL, PROTO, "BlockReps", options.block_reps ? 1 : 0);
	DBWriteContactSettingByte(NULL, PROTO, "LoggingEnabled", options.logging ? 1 : 0);

	DBWriteContactSettingWord(NULL, PROTO, "RespondingStatus", options.rstatus);
	DBWriteContactSettingWord(NULL, PROTO, "NotRespondingStatus", options.nrstatus);
	DBWriteContactSettingWord(NULL, PROTO, "TestingStatus", options.tstatus);
	DBWriteContactSettingWord(NULL, PROTO, "DisabledStatus", options.off_status);

	DBWriteContactSettingByte(NULL, PROTO, "NoTestStatus", options.no_test_status ? 1 : 0);
	DBWriteContactSettingByte(NULL, PROTO, "HideProtocol", options.hide_proto ? 1 : 0);
	DBWriteContactSettingByte(NULL, PROTO, "UseStatusMessage", options.use_status_msg ? 1 : 0);

	DBWriteContactSettingDword(NULL, PROTO, "Retries", options.retries);

	CallService(PROTO "/SetLogFilename", (WPARAM)MAX_PATH, (LPARAM)options.log_filename);

	ICMP::get_instance()->set_timeout(options.ping_timeout * 1000);
}
Пример #23
0
/** Set/unset (i.e. toggle) contact to force use of default contact
*
* Set the given contact to be the default one for the metacontact to which it is linked.
*
* @param wParam :	\c HANDLE to the MetaContact to be set as default
* @param lParam :	\c HWND to the clist window
					(This means the function has been called via the contact menu).
*/
INT_PTR Meta_ForceDefault(WPARAM wParam,LPARAM lParam)
{
	if(DBGetContactSettingDword((HANDLE)wParam,META_PROTO, META_ID, (DWORD)-1) != (DWORD)-1)
	{ // the wParam is a MetaContact

		BOOL current = DBGetContactSettingByte((HANDLE)wParam, META_PROTO, "ForceDefault", 0);
		current = !current;
		DBWriteContactSettingByte((HANDLE)wParam, META_PROTO, "ForceDefault", (BYTE)current);

		DBWriteContactSettingDword((HANDLE)wParam, META_PROTO, "ForceSend", 0);

		if(current) NotifyEventHooks(hEventForceSend, wParam, (LPARAM)Meta_GetContactHandle((HANDLE)wParam, DBGetContactSettingDword((HANDLE)wParam, META_PROTO, "Default", -1)));
		else NotifyEventHooks(hEventUnforceSend, wParam, 0);
	}
	return 0;
}
void save_listbox_items() {
	bool is_contact;


	for(int i = 0; i < listbox_items.getCount(); ++i) {
		is_contact = (int)CallService(MS_DB_CONTACT_IS, (WPARAM)listbox_items[i].hContact, 0) == 1;

		if(!is_contact) {
			listbox_items[i].hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
			CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )listbox_items[i].hContact, ( LPARAM )PROTO );	
			CallService(MS_IGNORE_IGNORE, (WPARAM)listbox_items[i].hContact, (WPARAM)IGNOREEVENT_USERONLINE);
		}

		DBWriteContactSettingTString(listbox_items[i].hContact, PROTO, "Nick", listbox_items[i].pszText);
		DBWriteContactSettingDword(listbox_items[i].hContact, PROTO, "TimezoneListIndex", listbox_items[i].timezone_list_index);
		DBWriteContactSettingWord(listbox_items[i].hContact, PROTO, "Status", ID_STATUS_ONLINE);
		DBWriteContactSettingTString(listbox_items[i].hContact, PROTO, "TZName", timezone_list[listbox_items[i].timezone_list_index].tcName);
	}
	DBWriteContactSettingWord(0, PROTO, "DataVersion", 1);

	// remove contacts in DB that have been removed from the list
	HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 );
	char *proto;
	bool found;
	while ( hContact != NULL ) {
		proto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 );
		if ( proto && !strcmp( PROTO, proto)) {
			found = false;
			for(int i = 0; i < listbox_items.getCount(); i++) {
				if(listbox_items[i].hContact == hContact) {
					found = true;
				}
			}

			if(!found) {
				// remove prot first, so that our contact deleted event handler (if present) isn't activated
				HANDLE oldHContact = hContact;
				hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 );

				CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)oldHContact, (LPARAM)PROTO);
				CallService(MS_DB_CONTACT_DELETE, (WPARAM)oldHContact, 0);
			} else
				hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 );
		} else
			hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 );
	}	
}
Пример #25
0
static void SetAvatar(HANDLE hContact, JABBER_LIST_ITEM *item, char *data, int len, DWORD format) {
	FILE* out;
	char filename[MAX_PATH];
	char md5[33];
	MD5 context;
	int i;
	md5_init(&context);
	md5_update(&context, data, len);
	md5_finalize(&context);
	if (format == PA_FORMAT_UNKNOWN && len > 4) {
		format = JabberGetPictureType(data);
	}
	for (i=0;i<16;i++) {
		char lo, hi;
		unsigned int j=context.state[i>>2];
		j>>=8*(i%4);
		j&=0xFF;
		lo = j & 0x0F;
		hi = j >> 4;
		hi = hi + ((hi > 9) ? 'a' - 10 : '0');
		lo = lo + ((lo > 9) ? 'a' - 10 : '0');
		md5[i*2] = hi;
		md5[i*2+1] = lo;
	}
	md5[i*2] = 0;
	if (item != NULL) {
		char *hash = item->avatarHash;
		item->avatarFormat = format;
		item->avatarHash = mir_strdup(md5);
		mir_free(hash);
	} else {
		jabberThreadInfo->avatarFormat = format;
		strcpy(jabberThreadInfo->avatarHash, md5);
	}
	TlenGetAvatarFileName(item, filename, sizeof filename );
	DeleteFileA(filename);
	out = fopen( filename, "wb" );
	if ( out != NULL ) {
		fwrite( data, len, 1, out );
		fclose( out );
		DBWriteContactSettingString(hContact, "ContactPhoto", "File", filename );
		DBWriteContactSettingString(hContact, jabberProtoName, "AvatarHash",  md5);
		DBWriteContactSettingDword(hContact, jabberProtoName, "AvatarFormat",  format);
	}
	ProtoBroadcastAck( jabberProtoName, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL , 0);
}
Пример #26
0
static void sttSendPrivateMessage( JABBER_LIST_ITEM* item, const TCHAR* nick )
{
	TCHAR szFullJid[ 256 ];
	mir_sntprintf( szFullJid, SIZEOF(szFullJid), _T("%s/%s"), item->jid, nick );
	HANDLE hContact = JabberDBCreateContact( szFullJid, NULL, TRUE, FALSE );
	if ( hContact != NULL ) {
		for ( int i=0; i < item->resourceCount; i++ ) {
			if ( _tcsicmp( item->resource[i].resourceName, nick ) == 0 ) {
				JSetWord( hContact, "Status", item->resource[i].status );
				break;
		}	}

		DBWriteContactSettingByte( hContact, "CList", "Hidden", 1 );
		JSetStringT( hContact, "Nick", nick );
		DBWriteContactSettingDword( hContact, "Ignore", "Mask1", 0 );
		JCallService( MS_MSG_SENDMESSAGE, ( WPARAM )hContact, 0 );
}	}
Пример #27
0
HANDLE DLL_CALLCONV 
MTI_TextUserAdd(const char *userTitle, DWORD options)
{
	TextUser *textUserNew = new TextUser;
	textUserNew->name = new char [lstrlenA(userTitle)+1];
	lstrcpyA(textUserNew->name, userTitle);
	textUserNew->options =
		(DBGetContactSettingDword(0, MODULNAME, userTitle, options)&MTEXT_FANCY_MASK) | (textUserNew->options&MTEXT_SYSTEM_MASK);
	DBWriteContactSettingDword(0, MODULNAME, userTitle, textUserNew->options);
	textUserNew->prev = textUserLast;
	textUserNew->next = 0;
	if (textUserLast)
	{
		textUserLast->next = textUserNew;
		textUserLast = textUserNew;
	} else
	{
		textUserFirst = textUserLast = textUserNew;
	}
	return (HANDLE)textUserNew;
}
Пример #28
0
int RegisterFontW(WPARAM wParam, LPARAM lParam) {
	FontIDW *font_id = (FontIDW *)wParam;
	FontSettingsW fontsettings;

	for(FontIDWList::Iterator i = font_id_list_w.start(); i.has_val(); i.next()) {
		if(wcscmp(i.val().first.group, font_id->group) == 0 && wcscmp(i.val().first.name, font_id->name) == 0)
			if((i.val().first.flags & FIDF_ALLOWREREGISTER) == 0)
				return 1;
	}

    char idstr[256];
	sprintf(idstr, "%sFlags", font_id->prefix);
	DBWriteContactSettingDword(0, font_id->dbSettingsGroup, idstr, font_id->flags);

	UpdateFontSettingsW(font_id, &fontsettings);

	FontIDSettingsWPair p(*font_id, fontsettings);
	font_id_list_w.add(p);

	return 0;
}
Пример #29
0
void ExtraIconGroup::applyIcon(HANDLE hContact)
{
	if (!isEnabled() || hContact == NULL)
		return;

	setValidExtraIcon = false;

	insideApply = true;

	unsigned int i;
	for (i = 0; i < items.size(); ++i)
	{
		items[i]->applyIcon(hContact);

		if (setValidExtraIcon)
			break;
	}

	insideApply = false;

	DBWriteContactSettingDword(hContact, MODULE_NAME, name.c_str(), setValidExtraIcon ? items[i]->getID() : 0);
}
Пример #30
0
void SetAllOffline() {
	char *proto;
	HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ), hContactNext;
	while ( hContact != NULL )
	{
		proto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 );
		if ( proto && !strcmp( PROTO, proto)) {
			if(DBGetContactSettingByte(hContact, PROTO, "ChatRoom", 0)) {
				// clean up after chat plugin
				hContactNext = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 );
				CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
				hContact = hContactNext;
				continue;
			} else {
				DBWriteContactSettingWord( hContact, PROTO, "Status", ID_STATUS_OFFLINE);
				DBWriteContactSettingDword(hContact, PROTO, "IdleTS", 0);
			}
		}

		hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 );
	}	
}