コード例 #1
0
ファイル: BDC.CPP プロジェクト: sverhagen/trillian-bdc
void CBDCApp::MakeIconRight(list_entry_t *pEntry, MEDIUM med)
{
	ASSERT(m_pproc);
	if( m_pproc && m_pproc->DrawRightIcons() )
	{
		if( med==MEDIUM_ICQ )
		{
			pEntry->right_icons		= (struct list_bmp_t *)malloc(sizeof(struct list_bmp_t));
			trillianInitialize((*pEntry->right_icons));
			
			pEntry->right_icons->num_states	= 1;

			pEntry->right_icons->skin_based = &sb;
			pEntry->right_icons->skin_name = &p1;
			pEntry->right_icons->skin_state = &p2;
			pEntry->right_icons->skin_type = &p3;

			pEntry->num_right_icons = 1;
		}
		else if( med==MEDIUM_VCARD )
		{
			pEntry->right_icons		= (struct list_bmp_t *)malloc(sizeof(struct list_bmp_t));
			trillianInitialize((*pEntry->right_icons));
			
			pEntry->right_icons->num_states	= 1;

			pEntry->right_icons->bitmap		= (HBITMAP *)malloc(sizeof(HBITMAP));
			pEntry->right_icons->bitmap[0]	= m_pbmpListentry_vcf;
			pEntry->right_icons->location	= (RECT *)malloc(sizeof(RECT));

			pEntry->right_icons->location[0].left	=  0;
			pEntry->right_icons->location[0].top	=  0;
			pEntry->right_icons->location[0].bottom	= 18;
			pEntry->right_icons->location[0].right	= 18;

			pEntry->num_right_icons = 1;
		}
		else if( med==MEDIUM_WAB )
		{
			pEntry->right_icons		= (struct list_bmp_t *)malloc(sizeof(struct list_bmp_t));
			trillianInitialize((*pEntry->right_icons));
			
			pEntry->right_icons->num_states	= 1;

			pEntry->right_icons->bitmap		= (HBITMAP *)malloc(sizeof(HBITMAP));
			pEntry->right_icons->bitmap[0]	= m_pbmpListentry_wab;
			pEntry->right_icons->location	= (RECT *)malloc(sizeof(RECT));

			pEntry->right_icons->location[0].left	=  0;
			pEntry->right_icons->location[0].top	=  0;
			pEntry->right_icons->location[0].bottom	= 18;
			pEntry->right_icons->location[0].right	= 18;

			pEntry->num_right_icons = 1;
		}
	}
}
コード例 #2
0
ファイル: BDC.CPP プロジェクト: sverhagen/trillian-bdc
void CBDCApp::MakeIconLeft(list_entry_t *pEntry, int nIcon)
{
	pEntry->left_icons = (struct list_bmp_t *)malloc(sizeof(struct list_bmp_t));
	trillianInitialize((*pEntry->left_icons));
	
	pEntry->left_icons->num_states	= 1;
	pEntry->left_icons->bitmap		= (HBITMAP *)malloc(sizeof(HBITMAP));
	pEntry->left_icons->location		= (RECT *)malloc(sizeof(RECT));

	switch( nIcon )
	{
		case 1:
			pEntry->left_icons->bitmap[0] = m_pbmpListentry_bd_confirmed;
			break;
		default:
			pEntry->left_icons->bitmap[0] = m_pbmpListentry_bd;
	}

	pEntry->left_icons->location[0].left	=  0;
	pEntry->left_icons->location[0].top		=  0;
	pEntry->left_icons->location[0].bottom	= 18;
	pEntry->left_icons->location[0].right	= 18;

	pEntry->num_left_icons = 1;
}
コード例 #3
0
ファイル: totrOtrl.cpp プロジェクト: damiangreen/trillianotr
    /* Report whether you think the given user is online.  Return 1 if
     * you think he is, 0 if you think he isn't, -1 if you're not sure.
     *
     * If you return 1, messages such as heartbeats or other
     * notifications may be sent to the user, which could result in "not
     * logged in" errors if you're wrong. */
int is_logged_in_cb(void* opdata, const char* accountname,
	    const char* protocol, const char* recipient)
{
	message_t* msg = reinterpret_cast<message_t*>(opdata);
	contactlist_enum_t cet;
	message_t status;
	int online = -1;

	if(!msg)
		return -1;

	trillianInitialize(cet);

	cet.medium = _strdup(protocol);
	cet.connection_id = msg->connection_id;
	cet.callback = userStatusLookupCallback;
	cet.data = &status;

	status.connection_id = msg->connection_id;
	status.extra_information = &online;
	status.medium = _strdup(protocol);
	status.name = _strdup(recipient);

	plugin_send(MYGUID, "contactlistEnumerate", &cet);

	Sleep(100);

	free(cet.medium);
	free(status.medium);
	free(status.name);

	cet.medium = status.medium = status.name = NULL;

	return online;
}
コード例 #4
0
ファイル: BDC.CPP プロジェクト: sverhagen/trillian-bdc
void CBDCApp::DrawToday()
{
	struct list_entry_t ple; 
	trillianListInitialize(ple);

	ple.section_id		= m_sectionID;
	ple.parent_id		= m_knowngroupID;
	ple.unique_id		= -1; 
	ple.group			= 0;
	ple.section			= 0; 
	ple.inline_editing	= 0;
	ple.drag_and_drop	= 0; 
	ple.expanded		= 1; 

	ple.font.flags = 0x1;
	ple.font.skin_name = "recent-online";
	ple.font.select_fore = "recent-online-fore";
	ple.font.hover_fore = "recent-online-fore";
	ple.font.normal_fore = "recent-online-fore";

	ASSERT( m_pproc );
	if( m_pproc )
		ple.previous_id	= m_pproc->GetNextID(&CDate());
	else
		ple.previous_id	= -1;

	CString c = CDate().GetDateString() + " (today)";
	ple.tooltip			= c.GetBuffer(0);
	ple.text			= c.GetBuffer(0);
	ple.data			= NULL;

	// icon
	ple.left_icons = (struct list_bmp_t *)malloc(sizeof(struct list_bmp_t));
	trillianInitialize((*ple.left_icons));

	ple.left_icons->num_states	= 1;
	ple.left_icons->bitmap		= (HBITMAP *)malloc(sizeof(HBITMAP));
	ple.left_icons->location		= (RECT *)malloc(sizeof(RECT));

	ple.left_icons->bitmap[0] = m_pbmpListentry_today;

	ple.left_icons->location[0].left	=  0;
	ple.left_icons->location[0].top		=  0;
	ple.left_icons->location[0].bottom	= 18;
	ple.left_icons->location[0].right	= 18;

	ple.num_left_icons = 1;

	// You'll need the UniqueID for any further manipulation, so store it somewhere nice
	m_todayID = m_plugin_send(MYGUID, "listAddEntry", (void *)&ple);

	// Free what needs to be freed
	FreeIcons(&ple);
}
コード例 #5
0
ファイル: BDC.CPP プロジェクト: sverhagen/trillian-bdc
void CBDCApp::Alert(CString text, void* data/*=NULL*/)
{
	alert_t at;
	trillianInitialize(at);
	// Make a systray alert
	at.text = text.GetBuffer(0);
	at.type = "default";
	at.callback = ::systrayCallback;
	at.data = data;

	m_plugin_send(MYGUID, "systraySetAlert",&at);
}
コード例 #6
0
ファイル: BDC.CPP プロジェクト: sverhagen/trillian-bdc
int CBDCApp::prefDialog(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
{
	switch( message )
	{
		case WM_COMMAND:
			switch( (int)LOWORD(wparam) )
			{
				case IDC_SUFFIX_NONE:
					EnableWindow(
						GetDlgItem( hWnd, IDC_DRAWLEFTINFO ), FALSE);
					break;
				case IDC_SUFFIX_AGE:
				case IDC_SUFFIX_YOB:
				case IDC_SUFFIX_YOB_SHORT:
				case IDC_SUFFIX_DATE:
					EnableWindow(
						GetDlgItem( hWnd, IDC_DRAWLEFTINFO ), TRUE);
					break;
				case IDC_IMPORTICQ:
					{
						struct contactlist_enum_t	cet2;
						trillianInitialize(cet2);
						cet2.connection_id = -1;			// No specific CID requested.
						cet2.medium = "ICQ";
						cet2.callback = CImportDlg::contactCallback;
						cet2.data = m_pproc;

						m_plugin_send(MYGUID, "contactlistEnumerate", &cet2);
					}
					return 0;
				case IDC_IMPORTVCF:
					{
						ASSERT(m_pproc);
						if(m_pproc) m_pproc->ImportVCF();
					}
					return 0;
				case IDC_IMPORTWAB:
					{
						ASSERT(m_pproc);
						if(m_pproc) m_pproc->ImportWAB();
					}
					return 0;
				default:
					break;
			}
		default:
			break;
	}

	ASSERT(m_pproc);
	if( m_pproc ) return m_pproc->prefDialog(hWnd, message, wparam, lparam, m_hInstance);
	return 0;
}
コード例 #7
0
ファイル: BDC.CPP プロジェクト: sverhagen/trillian-bdc
void CBDCApp::AddMenu(int id, char* text, menu_entry_t** pmenu_entry, void* pdata)
{
	menu_entry_t** pentry = pmenu_entry;
	while( *pentry != NULL )
	{
		pentry = &(*pentry)->next_menu;
	}

	*pentry = (struct menu_entry_t *)malloc(sizeof(struct menu_entry_t));
	trillianInitialize((**pentry));

	(*pentry)->menu_id = id;
	(*pentry)->type = MENU_TEXT;
	AssignString(&(*pentry)->text, text);
	(*pentry)->callback = ::menuCallback;
	(*pentry)->data = (void*)pdata;
}
コード例 #8
0
ファイル: totrOtrl.cpp プロジェクト: damiangreen/trillianotr
void totrNewContext(void* data, ConnContext* conn)
{

	TotrAppData *eopts = reinterpret_cast<TotrAppData*>(data);
	TotrAppData *appdata = new TotrAppData;
	edit_event_t eet;

	trillianInitialize(eet);
	appdata->connection_id = appdata->edit_event_id = appdata->window_id = -1;
	appdata->last_msg = NULL;
	appdata->last_msg_len = 0;

	/* If we have data to add, add it, and generate our edit event. Otherwise,
	 * just fill in the app_data fields
	 */
	if(eopts && eopts->window_id != -1)
	{
		appdata->connection_id = eopts->connection_id;
		eet.window_id = appdata->window_id = eopts->window_id;

		eet.event = "edit_sendText";
		eet.callback = totrEncryptMessage;
		eet.data = appdata;
	
		plugin_send(MYGUID, "editEventRegister", &eet);

		if(!eet.edit_event_id)
		{
			MessageBox(NULL, "Error registering edit event.", "Error", IDOK);
			delete eopts;
			return;
		}

		appdata->edit_event_id = eet.edit_event_id;
	}

	conn->app_data = appdata;
	conn->app_data_free = totrAppDataFree;
}
コード例 #9
0
ファイル: BDC.CPP プロジェクト: sverhagen/trillian-bdc
int CBDCApp::main(char *event, void *data)
{
	if( !_stricmp(event,"load") )
	{ 
	   struct plugin_info_t *pi = (struct plugin_info_t *)data;

	   if( pi )
	   {
			// Fill in plugin information
			strcpy_s(pi->guid, MYGUID); 
			strcpy_s(pi->name, "Birthday Calendar"); 
			strcpy_s(pi->company, "Totaal Software"); 
			strcpy_s(pi->version, VERSION); 
			strcpy_s(pi->description, "Keep track of your friends' birthdays.");
         
			// Extract what we need and store locally
			m_plugin_send = pi->plugin_send;
			m_homedir = CString( pi->config_directory );
	   }
	}
	else if( !_stricmp(event, "initialLoad"))
	{
		// First time a plugin is loaded
		// Can do install wizardish stuff here
	}
	else if( !_stricmp(event, "start") )
	{
		// Initialize
		if (m_pbmpListentry_vcf == NULL)
			m_pbmpListentry_vcf = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_VCF));
		if (m_pbmpListentry_wab == NULL)
			m_pbmpListentry_wab = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_WAB));
		if (m_pbmpListentry_bd == NULL)
			m_pbmpListentry_bd = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_BALLOONS));
		if (m_pbmpListentry_bd_confirmed == NULL)
			m_pbmpListentry_bd_confirmed = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_BALLOONS_CONFIRMED));
		if (m_pbmpListentry_known == NULL)
			m_pbmpListentry_known = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_BALLOONS_KNOWN));
		if (m_pbmpListentry_today == NULL)
			m_pbmpListentry_today = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_TODAY));
		if (m_pproc == NULL)
			m_pproc = new CProcessor(m_homedir,this);

		struct plugin_prefs_t pp;
		trillianInitialize(pp);
		// Initialize preferences.
		pp.enabled		= 1;
		pp.pref_name	= "Birthday Calendar"; 
		pp.sub_entry	= NULL; 
		m_plugin_send(MYGUID, "prefsInitialize", &pp); 

		// Populate contact list

		// Add the main section.
		{
			struct list_entry_t ple; 
			trillianListInitialize(ple);
			ple.previous_id		= -2;	// This controls placement of new entry, before (-2) or last (-1)
			ple.section			= 1;	// This is a section
			ple.expanded		= 1;	
			ple.tooltip			= "Birthday Calendar";
			ple.text			= "Birthdays";
			ple.real_name		= "birthdays";
			int i=m_plugin_send(MYGUID, "listAddEntry", (void *)&ple); 
				
			// Set our global sectionID for later. Note that we get the
			// sectionID from the structure after it's been populated
			m_sectionID = ple.section_id;
		}

		// Add the 'known' group
		// Flip section/group around
		// Group ID is the RETURN value, not in struct
		{
			struct list_entry_t ple; 
			trillianListInitialize(ple);
			ple.group			= 1;
			ple.section			= 0;
			ple.tooltip			= "Known Birthdays";
			ple.text			= "Known Birthdays"; 
			ple.section_id		= m_sectionID;

			// menu item: "ADD"
			ple.menu_entry = (struct menu_entry_t *)malloc(sizeof(struct menu_entry_t));
			trillianInitialize((*ple.menu_entry));
			
			ple.menu_entry->menu_id = MENU_ADD;
			ple.menu_entry->type = MENU_TEXT;
			AssignString(&ple.menu_entry->text, "&Add...");
			ple.menu_entry->callback = ::menuCallback;

			m_knowngroupID = m_plugin_send(MYGUID, "listAddEntry", (void *)&ple);

			free(ple.menu_entry->text);
			free(ple.menu_entry);
		}

		ASSERT(m_pproc);
		if( m_pproc )
		{
			m_pproc->PopulateKnowns();
			m_pproc->ProcessAction();
		}
	}
	else if( !_stricmp(event,"stop") && m_plugin_send )
	{
		// Remove list items
		ASSERT(m_pproc);
		if( m_pproc )
			m_pproc->DepopulateKnowns();
		// Remove the 'known' group
		{
			struct list_entry_t ple;
			trillianListInitialize(ple);
			ple.unique_id = m_knowngroupID;
			ple.section_id = -1;
			ple.parent_id = -1;
			ple.previous_id = -1;
			m_plugin_send(MYGUID, "listRemoveEntry", (void *)&ple);
		}
		// Remove the section
		{
			struct list_entry_t ple;
			trillianListInitialize(ple);
			ple.unique_id = -1;
			ple.section_id = m_sectionID;
			ple.parent_id = -1;
			ple.previous_id = -1;
			m_plugin_send(MYGUID, "listRemoveEntry", (void *)&ple);
		}
		// Clear up some variables
		if(m_pbmpListentry_vcf)
		{
			DeleteObject(m_pbmpListentry_vcf);
			m_pbmpListentry_vcf = NULL;
		}
		if(m_pbmpListentry_wab)
		{
			DeleteObject(m_pbmpListentry_wab);
			m_pbmpListentry_wab = NULL;
		}
		if(m_pbmpListentry_bd)
		{
			DeleteObject(m_pbmpListentry_bd);
			m_pbmpListentry_bd = NULL;
		}
		if(m_pbmpListentry_bd_confirmed)
		{
			DeleteObject(m_pbmpListentry_bd_confirmed);
			m_pbmpListentry_bd_confirmed = NULL;
		}
		if(m_pbmpListentry_known)
		{
			DeleteObject(m_pbmpListentry_known);
			m_pbmpListentry_known = NULL;
		}
		if(m_pbmpListentry_today)
		{
			DeleteObject(m_pbmpListentry_today);
			m_pbmpListentry_today = NULL;
		}
		if(m_pproc)
		{
			delete m_pproc;
			m_pproc = NULL;
		}
	}
	else if( !_stricmp(event, "unload") )
	{
		m_plugin_send = NULL;
	}
	else if( !_stricmp(event, "prefsShow") )
	{
		struct plugin_prefs_show_t	*pps = (struct plugin_prefs_show_t *)data;

		// Trillian is telling us to show our preferences
		// dialog do so only if we find our name

		if( !strcmp(pps->pref_name, "Birthday Calendar") )
		{
			int prefDialog();

			strcpy_s(pps->prefs_info.name, "Birthday Calendar");
			strcpy_s(pps->prefs_info.description, "Keep track of your friends' birthdays.");
			pps->prefs_info.bitmap = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_PREFSLOGO));

			if( pps->show==1 )
			{
				if( m_prefswnd==NULL )
				{
					struct dialog_entry_t det;
					trillianInitialize(det);						
					det.hwnd = CreateDialog(m_hInstance, MAKEINTRESOURCE(IDD_PREFS_DIALOG), pps->hwnd, (DLGPROC)::prefDialog);
					m_plugin_send(MYGUID, "dialogAdd", &det);   
					m_prefswnd = det.hwnd;

					SetWindowPos(m_prefswnd, 0, pps->x, pps->y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

					ASSERT(m_pproc);
					if( m_pproc )
						m_pproc->PrefsShow(m_prefswnd);
				}
				ShowWindow(m_prefswnd, SW_SHOW);
			}	else
			if( pps->show==0 )
			{
				if( m_prefswnd!=NULL )
					ShowWindow(m_prefswnd, SW_HIDE);
			}
		}
	}
	else if( !_stricmp(event, "prefsAction") )
	{
		struct plugin_prefs_action_t *ppa
			= (struct plugin_prefs_action_t *)data;

		// Take action:
		// 0 - Cancel
		// 1 - Apply
		// 2 - OK

		if( ppa->type==0 )
		{
			if( m_prefswnd!=NULL )
			{
				struct dialog_entry_t det;
				trillianInitialize( det );
				det.hwnd = m_prefswnd;
				m_plugin_send(MYGUID, "dialogRemove", &det);
				DestroyWindow(m_prefswnd);
				m_prefswnd = NULL;
			}
		}
		if( (ppa->type==1) || (ppa->type==2) )
		{
			ASSERT(m_pproc);
			if( m_prefswnd && m_pproc )
			{
				m_pproc->PrefsAction(m_prefswnd);
			}
		}
		if( ppa->type==2 )
		{
			if( m_prefswnd!=NULL )
			{
				struct dialog_entry_t det;
				trillianInitialize( det );
				det.hwnd = m_prefswnd;
				m_plugin_send(MYGUID, "dialogRemove", &det);
				DestroyWindow(m_prefswnd);
				m_prefswnd = NULL;
			}
		}		
	}

	return 0; 
}
コード例 #10
0
ファイル: BDC.CPP プロジェクト: sverhagen/trillian-bdc
void CBDCApp::DrawKnown(CBirthday *pbd, bool bSorted/*=true*/)
{
	struct list_entry_t ple;

	trillianListInitialize(ple);

	ple.section_id		= m_sectionID;
	ple.parent_id		= m_knowngroupID;
	ple.unique_id		= -1; 
	ple.group			= 0;
	ple.section			= 0; 
	ple.inline_editing	= 0;
	ple.drag_and_drop	= 0; 
	ple.expanded		= 1; 
	ple.callback		= ::listCallback;

	ASSERT( m_pproc );
	if( bSorted && m_pproc )
		ple.previous_id	= m_pproc->GetPreviousID(pbd);
	else
		ple.previous_id	= -1;

	AssignString(&ple.tooltip, pbd->GetTooltip());
	ASSERT(m_pproc);
	if( m_pproc )
	{
		AssignString(&ple.text, pbd->GetText(m_pproc->GetSuffix(), m_pproc->DrawLeftInfo()));
	}
	else
	{
		AssignString(&ple.text, pbd->GetText(SUFFIX_NONE));
	}

	ple.data			= (void*)pbd;

	// left icon
	ple.left_icons		= (struct list_bmp_t *)malloc(sizeof(struct list_bmp_t));
	trillianInitialize((*ple.left_icons));
	
	ple.left_icons->num_states	= 1;

	ple.left_icons->bitmap		= (HBITMAP *)malloc(sizeof(HBITMAP));
	ple.left_icons->bitmap[0]	= m_pbmpListentry_known;

	ple.left_icons->location	= (RECT *)malloc(sizeof(RECT));
	ple.left_icons->location[0].left	=  0;
	ple.left_icons->location[0].top		=  0;
	ple.left_icons->location[0].bottom	= 18;
	ple.left_icons->location[0].right	= 18;

	ple.num_left_icons = 1;

	// right icon
	MakeIconRight( &ple,
		pbd->m_medium);

	AddMenu(MENU_ADD, "&Add...", &ple.menu_entry);
	AddMenu(MENU_EDIT, "&Edit...", &ple.menu_entry, pbd);
	AddMenu(MENU_REMOVE, "&Remove...", &ple.menu_entry, pbd);

	if( pbd->m_medium == MEDIUM_ICQ )
	{
		AddMenu(MENU_RELOAD, "Re&load...", &ple.menu_entry, pbd);
	}

	// You'll need the UniqueID for any further manipulation, so store it somewhere nice
	pbd->m_listid_known = m_plugin_send(MYGUID, "listAddEntry", (void *)&ple); 

	FreeMenus(&ple.menu_entry);
	free(ple.text);
	free(ple.tooltip);
	FreeIcons(&ple);
}
コード例 #11
0
ファイル: totrOtrl.cpp プロジェクト: damiangreen/trillianotr
int totrEncryptMessage(int windowID, char* subwindow, char* event, void* data, void* userData) 
{
	edit_event_t* msg = reinterpret_cast<edit_event_t*>(data);
	TotrAppData* eopts = reinterpret_cast<TotrAppData*>(userData);
	char* message = NULL;
	char* newmessage = NULL;
	char* account_name = NULL;
	int res = -1;
	int connection_id = -1;
	ConnContext* conn = userstate->context_root;
	//CAtlRegExp<> reStart, reEnd;
	//CAtlREMatchContext<> mcStart, mcEnd;
	BOOL resStart = FALSE;
	BOOL resEnd = FALSE;

	if(!msg || !reinterpret_cast<char*>(msg->data)
		|| stricmp(event, "edit_sendText") != 0 || !strlen(reinterpret_cast<char*>(msg->data))
		|| (reinterpret_cast<char*>(msg->data)[0]) == '/')
		return 0;
	/* Bail out of parsing any messages starting with /
		* Too bad we can't tell if this is a real command
		* or not without doing some interpretive lists.
		* Even then, such lists would not include other
		* plugins that impliment their own / commands.
		*
		* May need to exclude everything and include
		* /me. Unsure of that.
		*/

	while(conn)
	{
		if(conn->app_data != NULL)
		{
			TotrAppData *appdata = reinterpret_cast<TotrAppData*>(conn->app_data);

			if(appdata->window_id == msg->window_id)
			{
				connection_id = appdata->connection_id;
				break;
			}
		}
		conn = conn->next;
	}

	if(connection_id == -1)
		return 0;

	account_name = accountNameLookup(conn->protocol, connection_id);

	if(!account_name)
		return 0;

	/* Cleanse our text string of the <cursor/> tag Trillian puts in */
	message = _strdup(reinterpret_cast<char*>(msg->data));
	stripCursorTag(message,reinterpret_cast<char*>(msg->data));

#if 0
	char *search = strstr((char *) msg->data, "<cursor/>");

	if (search) {
		char *c = NULL, *s = NULL;
		size_t bufsize=strlen((char *)msg->data)-strlen("<cursor/>")+1;
		c = message = (char *)malloc(bufsize);
		ZeroMemory(c,bufsize);
		ZeroMemory(message,bufsize);
		strncpy(message, (char *)msg->data, search-((char *) msg->data));
		c = c + (search - (char *) msg->data);
		s = search + strlen("<cursor/>");
		strncpy(c, s, strlen(search)-strlen("<cursor/>")+1);
	}
	else
		message = _strdup(reinterpret_cast<char*>(msg->data));

#endif

	res = otrl_message_sending(userstate, &totr_ops, msg,
		account_name, conn->protocol, conn->username, message, 
		NULL, &newmessage, totrNewContext, eopts);

	if(res && !newmessage)
		newmessage = "";
		
	if(newmessage)
	{
		if(totr_config.GetSaveHistory()) 
			if(!totr_config.appendHistory(message,conn->protocol,account_name,conn->username))
				MessageBox(NULL,"Could not save history","ERROR",MB_OK); // Added by Thisita 10/22/11

		message_t msg2;
		message_options_t mopts;
		edit_event_t eet;
		int psres = -1;

		trillianInitialize(msg2);
		trillianInitialize(eet);
		
		memset(&mopts, -1, sizeof(mopts));
		mopts.struct_size = sizeof(mopts);
		mopts.disable_message = mopts.logging_name = mopts.echo_name = NULL;
		mopts.nicklist = NULL;

		reinterpret_cast<TotrAppData*>(conn->app_data)->last_msg = 
			_strdup(reinterpret_cast<char*>(msg->data));
		reinterpret_cast<TotrAppData*>(conn->app_data)->last_msg_len = 
			strlen(reinterpret_cast<char*>(msg->data)) + 1;
	

		eet.window_id = msg->window_id;
		eet.event = "edit_setText";

		if(strlen(newmessage) != 0)
		{
			msg2.connection_id = connection_id;
			msg2.window_id = msg->window_id;
			msg2.name = conn->username;
			msg2.medium = conn->protocol;
			msg2.text = "";
			//msg2.text = _strdup(newmessage);
			msg2.text_len = static_cast<int>(strlen(newmessage) + 1); // Change proposed by Thisita 10/20/11
			msg2.type = "outgoing_privateMessage";
			msg2.extra_information = &mopts;
			msg2.extra_information_size = mopts.struct_size;
			eet.data = newmessage;

			OutputDebugString("sent ");
			OutputDebugString(newmessage);

			if(otrl_proto_message_type(newmessage) != OTRL_MSGTYPE_TAGGEDPLAINTEXT)
			{
				messageWindowEchostate(&msg2, 1);
				psres = plugin_send(MYGUID, "editEventSend", &eet);
				msg2.type="outgoing_privateMessage";
				msg2.text = message; //<HTML><BODY BGCOLOR=\"#ffffff\">greets</BODY></HTML>";
				plugin_send(MYGUID, "messageReceive", &msg2);
			}
		}
	}

	otrl_message_free(newmessage);
	free(account_name);
	account_name = NULL;

	return 0;
}
コード例 #12
0
ファイル: totrOtrl.cpp プロジェクト: damiangreen/trillianotr
    /* Send the given IM to the given recipient from the given
     * accountname/protocol. */
void inject_message_cb(void* opdata, const char* accountname,
	    const char* protocol, const char* recipient, const char* message)
{
	message_t outmsg;
	message_options_t outmsgopts;
	message_t* msg = reinterpret_cast<message_t*>(opdata);
	char* account_name = NULL;
	ConnContext* conn = NULL;
	TotrAppData* appdata = NULL;
	int err;

	/* Forcibly attempting to create an OTR connection to a mobile device will
	 * do so, with mixed results. This is partly instigated through our UI, as
	 * there is no direct otrl_...() call that fires off a new conversation.
	 *
	 * If OTR won't do this for us, we should validate against our own
	 * is_logged_in_cb callback function that the user is online before sending.
	 */

	trillianInitialize(outmsg);

	memset(&outmsgopts, -1, sizeof(outmsgopts));
	outmsgopts.struct_size = sizeof(outmsgopts);
	outmsgopts.disable_message = outmsgopts.logging_name = outmsgopts.echo_name = NULL;
	outmsgopts.nicklist = NULL;

	/* Build our message to inject */
	if(msg)
	{
		outmsg.connection_id = msg->connection_id;
		outmsg.type = "outgoing";

		outmsg.medium = msg->medium;
		outmsg.name = msg->name;
	}
	else
	{
		outmsg.type = "outgoing";

		outmsg.medium = _strdup(protocol);
		outmsg.name = _strdup(recipient);
		outmsg.display_name = _strdup(account_name);
		/* Turn echoing off */
		messageWindowEchostate(&outmsg, 1);

		outmsg.text = _strdup(message);
		outmsg.text_len = static_cast<int>(strlen(message) + 1);
		OutputDebugString("sent ");
		OutputDebugString(message);

		/* Fire in the hole! */
		err = plugin_send(MYGUID, "messageSend", &outmsg);
		/* Turn echoing back on. We're all done now */
		messageWindowEchostate(&outmsg, 0);

		delete [] outmsg.text;
		delete [] outmsg.name;
		delete [] outmsg.medium;
		delete [] outmsg.display_name;

		return;
	}

	/* Check to see if we have a window already. We need this
	 * for echo control.
	 */
	if(msg->window_id == -1)
	{

		/* Open a window. */
		err = plugin_send(MYGUID, "messageSend", &outmsg);
		OutputDebugString("sent ");
		OutputDebugString(message);

		/* Now, find it */
		account_name = accountNameLookup(msg->medium, msg->connection_id);
		conn = otrl_context_find(userstate, msg->name, account_name, msg->medium,
			0, NULL, NULL, NULL);

		/* And fill in our window_ids */
		if(conn)
		{
			appdata = reinterpret_cast<TotrAppData*>(conn->app_data);
			if(appdata)
				outmsg.window_id = msg->window_id = appdata->window_id;
		}

		/* Don't forget to clean up our account name */
		free(account_name);
		account_name;
	}

	/* Turn echoing off */
	messageWindowEchostate(msg, 1);

	//outmsg.text = new char [strlen(message)];
	outmsg.text = _strdup(message); // Fix suggested by http://forums.ceruleanstudios.com/showpost.php?p=831067&postcount=88
	outmsg.text_len = static_cast<int>(strlen(message) + 1);
	//sprintf_s(outmsg.text,outmsg.text_len, "%s", message);
	//_snprintf(outmsg.text, outmsg.text_len, "%s", message);
	OutputDebugString("sent ");
	OutputDebugString(message);

	/* Fire in the hole! */
	err = plugin_send(MYGUID, "messageSend", &outmsg);
	/* Turn echoing back on. We're all done now */
	messageWindowEchostate(msg, 0);

	delete [] outmsg.text;
}
コード例 #13
0
ファイル: main.c プロジェクト: Adolphsson/Spotian
int __declspec(dllexport)plugin_main(char *event, void *data) 
{   
	struct config_t config;
	
	HRSRC src;
	char ver[50] = {0};
	char* fileName;
	DWORD dwHandle;
	DWORD dwLen;
	unsigned int BufLen;
	char* lpData;
	VS_FIXEDFILEINFO* pFileInfo;

	if (!_stricmp(event,"load")) { 
	   struct plugin_info_t *pi = (struct plugin_info_t *)data;

	   fileName = (char*)malloc(_MAX_DIR);
	   GetModuleFileName(GetModuleHandle("spotian"), fileName, _MAX_DIR);

	   dwLen = GetFileVersionInfoSize(fileName, &dwHandle);
	   lpData = (char*)malloc(dwLen);
	   GetFileVersionInfo( fileName, dwHandle, dwLen, lpData);

	   VerQueryValue(lpData, "\\", (LPVOID*)(&pFileInfo), (PUINT)(&BufLen));
	   majver = HIWORD(pFileInfo->dwFileVersionMS);
	   minver = LOWORD(pFileInfo->dwFileVersionMS);
	   patch = HIWORD(pFileInfo->dwFileVersionLS);
	   build = LOWORD(pFileInfo->dwFileVersionLS);

	   free(lpData);
	   free(fileName);

	   _snprintf_s(ver, 50, 49, "%d.%d.%d (Build %d)",
				majver, minver, patch, build);
	   //version = reinterpret_cast<char*>(malloc(strlen(ver)+1));
	   //strncpy_s(version, strlen(version) + 1, ver, _TRUNCATE);
	   version = _strdup(ver);

	   _snprintf_s(ver, 50, 49, "%d.%d.%d",
				majver, minver, patch);
	   //shortver = reinterpret_cast<char*>(malloc(strlen(ver)+1));
	   //strcpy(shortver, ver);
	   shortver = _strdup(ver);

	   _snprintf_s(ver, 50, 49, "%d.%d.%d.%d",
				majver, minver, patch, build);
	   //updatever = reinterpret_cast<char*>(malloc(strlen(ver)+1));
	   //strcpy(updatever, ver);
	   updatever = _strdup(ver);

	   if (pi) {

			/* Fill in plugin information.
			 */

			strcpy(pi->guid, MYGUID); 
			strcpy(pi->name, MYNAME); 
			strcpy(pi->company, COMPANY);
			strcpy(pi->version, _strdup(shortver)); 
			strcpy(pi->description, DESCRIPTION);
			pi->png_image_32 = image32;
			pi->png_image_32_len = sizeof(image32);
			pi->png_image_48 = image48;
			pi->png_image_48_len = sizeof(image48);
			/* Extract what we need and store locally.
			 */

			home_directory = (char *)malloc(strlen(pi->config_directory)+1);
			strcpy(home_directory, pi->config_directory);

			plugin_send = pi->plugin_send;
	   } 
	} else if (!_stricmp(event, "initialLoad")) {

		/* First time a plugin is loaded - can do install wizardish stuff here.
		 */

	} else if (!_stricmp(event, "start")) {
		
		struct plugin_prefs_t		pp;
		struct plugin_prefs_entry_t pp_advanced;
		struct plugin_prefs_entry_t pp_basic;
		struct http_request_t       hr;

		trillianInitialize(pp);
		trillianInitialize(pp_advanced);
		trillianInitialize(pp_basic);
		trillianInitialize(hr);

		util_readConfig(&config);

		/* Initialize preferences.
		 */

		pp.enabled						= 1; 
		pp.pref_name					= "Spotian";
		pp.sub_entry					= NULL; /*&pp_basic;*/

		pp_advanced.sub_name			= "Basic"; 
		/* pp_advanced.next				= &pp_advanced; */
		pp_advanced.next				= NULL;

		pp_advanced.sub_name			= "Advanced"; 
		pp_advanced.next				= NULL;

		plugin_send(MYGUID, "prefsInitialize", &pp);

		m_exit = 0;
		CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)CheckSpotify, NULL, NULL, &thread_id);

		hr.url = (char*)malloc(sizeof(char)*64);
		sprintf(hr.url, "http://adolphsson.se/xsa?v=%s", shortver);
		hr.callback = httpCallback;
		
		if(m_config.check_for_updates)
			plugin_send(MYGUID, "httpFileRequest", &hr);

	} else if (!_stricmp(event,"stop") && plugin_send) {
		m_exit = 1;
		/* Give the thread some time to terminate */
		Sleep(1000);
		
		/* Write our configuration.
		 */
		util_writeConfig(&m_config);

	} else if (!_stricmp(event, "unload")) {			

		/* Clean up. 
		 */

		if (home_directory) {
			free(home_directory);
			home_directory = NULL;
		}

		if (prefs_window != NULL) { 
			myDestroyWindow(prefs_window); 
			prefs_window = NULL; 
		} 

		plugin_send = NULL;

		if(version != NULL)
		{
			free(version);
			version = NULL;
		}
		if(shortver != NULL)
		{
			free(shortver);
			shortver = NULL;
		}
		if(updatever != NULL)
		{
			free(updatever);
			updatever = NULL;
		}

		return 0;
	} else if (!_stricmp(event, "finalUnload")) {

		/* 
		 * Final unload means the plugin is actually being removed.  Plugins should clean up
		 * saved settings here (delete INI files, etc).
		 */

	} else if (!_stricmp(event, "prefsShow")) {
		struct plugin_prefs_show_t	*pps = (struct plugin_prefs_show_t *)data;
		/* 
		 * Trillian is telling us to show our preferences dialog - do so only if we find our
		 * name.
		 */

		if (!strcmp(pps->pref_name, "Spotian")) {
			int				prefDialog();

			strcpy(pps->prefs_info.name, "Spotian Plugin");
			strcpy(pps->prefs_info.description, "Spotify Integration");

			/* This can be an HBITMAP if you've got a pretty icon for your preferences screen.
			 */

			pps->prefs_info.bitmap = 0;

			/* Show or hide?
			 */
			
			if (pps->show == TRILLIAN_PREFS_SHOW) {
				
				if (prefs_window == NULL) {
					prefs_window = myCreateDialog(hInstance, MAKEINTRESOURCE(IDD_PREFS_DIALOG), pps->hwnd, (DLGPROC)prefDialog);
					SetWindowPos(prefs_window, HWND_TOP, pps->x, pps->y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
					prefInit(&m_config);
				}
				
				ShowWindow(prefs_window, SW_SHOW);
			} else if (pps->show == TRILLIAN_PREFS_HIDE) {
				if (prefs_window != NULL)
					ShowWindow(prefs_window, SW_HIDE);
			}
		}
		else if (!strcmp(pps->pref_name, "Advanced")) {
			int				prefDialog();

			strcpy(pps->prefs_info.name, "Spotian Plugin");
			strcpy(pps->prefs_info.description, "Spotify Integration");

			/* This can be an HBITMAP if you've got a pretty icon for your preferences screen.
			 */

			pps->prefs_info.bitmap = 0;

			/* Show or hide?
			 */
			
			if (pps->show == TRILLIAN_PREFS_SHOW) {
				
				if (prefs_window == NULL) {
					prefs_window = myCreateDialog(hInstance, MAKEINTRESOURCE(IDD_ADVANCED_DIALOG), pps->hwnd, (DLGPROC)prefDialog);
					SetWindowPos(prefs_window, HWND_TOP, pps->x, pps->y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
					prefInit(&m_config);
				}
				
				ShowWindow(prefs_window, SW_SHOW);
			} else if (pps->show == TRILLIAN_PREFS_HIDE) {
				if (prefs_window != NULL)
					ShowWindow(prefs_window, SW_HIDE);
			}
		}
	} else if (!_stricmp(event, "prefsAction")) {
		struct plugin_prefs_action_t	*ppa = (struct plugin_prefs_action_t *)data;

		/* Take action:
		 *
		 * 0 - Cancel
		 * 1 - Apply
		 * 2 - OK
		 */

		switch(ppa->type)
		{
			case TRILLIAN_PREFS_APPLY:
				if (prefs_window != NULL) {
					if(prefResult(&config))
						util_writeConfig(&config);
				}
				break;
			case TRILLIAN_PREFS_OK:
				if (prefs_window != NULL) {
					if(prefResult(&config))
						util_writeConfig(&config);
				}
			case TRILLIAN_PREFS_CANCEL:
				if (prefs_window != NULL) {
					myDestroyWindow(prefs_window);
					prefs_window = NULL;
				}
		}		
	}

	return 0; 
}