Exemplo n.º 1
0
void RegistrationManager::send(const Jreen::RegistrationData &data)
{
	Q_D(RegistrationManager);
	ConnectionIQ iq(IQ::Set, d->service);
	iq.addPayload(new RegistrationQuery(data));
	d->sendIQ(iq, SLOT(_q_result_received(Jreen::IQ)));
}
Exemplo n.º 2
0
 void Client::createSession()
 {
   notifyStreamEvent( StreamEventSessionCreation );
   IQ iq( IQ::Set, JID(), getID() );
   iq.addExtension( new SessionCreation() );
   send( iq, this, CtxSessionEstablishment );
 }
static int JabbeSearchrRenewFields(HWND hwndDlg, JabberSearchData * dat)
{
	char szServerName[100];
	EnableWindow(GetDlgItem(hwndDlg, IDC_GO),FALSE);
	GetDlgItemTextA(hwndDlg,IDC_SERVER,szServerName,sizeof(szServerName));
	dat->CurrentHeight = 0;
	dat->curPos = 0;
	SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, 0, FALSE );

	JabberSearchFreeData( hwndDlg, dat );
	JabberSearchRefreshFrameScroll( hwndDlg, dat );
	

	if ( jabberOnline )
		SetDlgItemText(hwndDlg,IDC_INSTRUCTIONS,TranslateT("Please wait...\r\nConnecting search server..."));
	else
		SetDlgItemText(hwndDlg,IDC_INSTRUCTIONS,TranslateT("You have to be connected to server"));

	if ( !jabberOnline )
		return 0;

	searchHandleDlg = hwndDlg;

	int iqId = JabberSerialNext();
	XmlNodeIq iq( "get", iqId, szServerName );
	XmlNode* query = iq.addChild( "query" );
	query->addAttr( "xmlns", "jabber:iq:search" );
	JabberIqAdd( iqId, IQ_PROC_GETSEARCHFIELDS, JabberIqResultGetSearchFields );
	JabberSend( jabberThreadInfo->s, iq );
	return iqId;
}
Exemplo n.º 4
0
BOOL CJabberProto::OnIqProcessIqOldTime(HXML, CJabberIqInfo *pInfo)
{
	struct tm *gmt;
	time_t ltime;
	TCHAR stime[100], *dtime;

	_tzset();
	time(&ltime);
	gmt = gmtime(&ltime);
	mir_sntprintf(stime, _countof(stime), _T("%.4i%.2i%.2iT%.2i:%.2i:%.2i"),
		gmt->tm_year + 1900, gmt->tm_mon + 1,
		gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
	dtime = _tctime(&ltime);
	dtime[24] = 0;

	XmlNodeIq iq(_T("result"), pInfo);
	HXML queryNode = iq << XQUERY(JABBER_FEAT_ENTITY_TIME_OLD);
	queryNode << XCHILD(_T("utc"), stime);
	LPCTSTR szTZName = TimeZone_GetName(NULL);
	if (szTZName)
		queryNode << XCHILD(_T("tz"), szTZName);
	queryNode << XCHILD(_T("display"), dtime);
	m_ThreadInfo->send(iq);
	return TRUE;
}
Exemplo n.º 5
0
VCardReply *VCardManager::store(const Jreen::VCard::Ptr &vcard)
{
	Q_D(VCardManager);
	IQ iq(IQ::Set, JID());
	iq.addExtension(vcard);
	return new VCardReply(d->client->jid().bareJID(), NULL, d->client->send(iq));
}
Exemplo n.º 6
0
/**
 * Send game report containing numerous game properties to the server.
 *
 * @param data A JS array of game statistics
 */
void XmppClient::SendIqGameReport(ScriptInterface& scriptInterface, CScriptVal data)
{
	glooxwrapper::JID xpartamuppJid(m_xpartamuppId);
	jsval dataval = data.get();

	// Setup some base stanza attributes
	GameReport* game = new GameReport();
	glooxwrapper::Tag* report = glooxwrapper::Tag::allocate("game");

	// Iterate through all the properties reported and add them to the stanza.
	std::vector<std::string> properties;
	scriptInterface.EnumeratePropertyNamesWithPrefix(dataval, "", properties);
	for (std::vector<int>::size_type i = 0; i != properties.size(); i++)
	{
		std::wstring value;
		scriptInterface.GetProperty(dataval, properties[i].c_str(), value);
		report->addAttribute(properties[i], utf8_from_wstring(value));
	}

	// Add stanza to IQ
	game->m_GameReport.push_back(report);

	// Send IQ
	glooxwrapper::IQ iq(gloox::IQ::Set, xpartamuppJid);
	iq.addExtension(game);
	DbgXMPP("SendGameReport [" << tag_xml(iq) << "]");
	m_client->send(iq);
};
Exemplo n.º 7
0
/**
 * Send a request to register a game to the server.
 *
 * @param data A JS array of game attributes
 */
void XmppClient::SendIqRegisterGame(ScriptInterface& scriptInterface, CScriptVal data)
{
	glooxwrapper::JID xpartamuppJid(m_xpartamuppId);
	jsval dataval = data.get();

	// Setup some base stanza attributes
	GameListQuery* g = new GameListQuery();
	g->m_Command = "register";
	glooxwrapper::Tag* game = glooxwrapper::Tag::allocate("game");
	// Add a fake ip which will be overwritten by the ip stamp XMPP module on the server.
	game->addAttribute("ip", "fake");

	// Iterate through all the properties reported and add them to the stanza.
	std::vector<std::string> properties;
	scriptInterface.EnumeratePropertyNamesWithPrefix(dataval, "", properties);
	for (std::vector<int>::size_type i = 0; i != properties.size(); i++)
	{
		std::wstring value;
		scriptInterface.GetProperty(dataval, properties[i].c_str(), value);
		game->addAttribute(properties[i], utf8_from_wstring(value));
	}

	// Push the stanza onto the IQ
	g->m_GameList.push_back(game);

	// Send IQ
	glooxwrapper::IQ iq(gloox::IQ::Set, xpartamuppJid);
	iq.addExtension(g);
	DbgXMPP("SendIqRegisterGame [" << tag_xml(iq) << "]");
	m_client->send(iq);
}
Exemplo n.º 8
0
	void btnRemove_OnClick(CCtrlFilterListView *)
	{
		if (!m_proto->m_bJabberOnline) return;

		int iItem = m_lvBookmarks.GetNextItem(-1, LVNI_SELECTED);
		if (iItem < 0) return;

		TCHAR *address = (TCHAR *)m_lvBookmarks.GetItemData(iItem);
		if (address == NULL) return;

		JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
		if (item == NULL) return;

		m_btnAdd.Disable();
		m_btnEdit.Disable();
		m_btnRemove.Disable();

		m_proto->ListRemove(LIST_BOOKMARK, address);

		m_lvBookmarks.SetItemState(iItem, 0, LVIS_SELECTED); // Unselect the item

		XmlNodeIq iq( m_proto->AddIQ(&CJabberProto::OnIqResultSetBookmarks, JABBER_IQ_TYPE_SET));
		m_proto->SetBookmarkRequest(iq);
		m_proto->m_ThreadInfo->send(iq);
	}
Exemplo n.º 9
0
static void JabberAdminSet( const TCHAR* to, const char* ns, const char* szItem, const TCHAR* itemVal, const char* var, const TCHAR* varVal )
{
	XmlNodeIq iq( "set", NOID, to );
	XmlNode* query = iq.addQuery( ns );
	XmlNode* item = query->addChild( "item" ); item->addAttr( szItem, itemVal ); item->addAttr( var, varVal );
	JabberSend( jabberThreadInfo->s, iq );
}
Exemplo n.º 10
0
void SOCKS5BytestreamManager::rejectSOCKS5Bytestream( const JID& from,
        const std::string& id,
        StanzaError reason )
{
    IQ iq( IQ::Error, from, id );

    switch( reason )
    {
    case StanzaErrorForbidden:
    case StanzaErrorNotAcceptable:
    {
        iq.addExtension( new Error( StanzaErrorTypeAuth, reason ) );
        break;
    }
    case StanzaErrorFeatureNotImplemented:
    case StanzaErrorNotAllowed:
    default:
    {
        iq.addExtension( new Error( StanzaErrorTypeCancel, reason ) );
        break;
    }
    }

    m_parent->send( iq );
}
Exemplo n.º 11
0
void CJabberProto::SetMucConfig( HXML node, void *from )
{
	if ( m_ThreadInfo && from ) {
		XmlNodeIq iq( _T("set"), SerialNext(), ( TCHAR* )from );
		HXML query = iq << XQUERY( xmlnsOwner );
		xmlAddChild( query, node );
		m_ThreadInfo->send( iq );
}	}
Exemplo n.º 12
0
 void FlexibleOffline::messageOperation( int context, const StringList& msgs )
 {
   const std::string& id = m_parent->getID();
   IQ::IqType iqType = context == FORequestMsgs ? IQ::Get : IQ::Set;
   IQ iq( iqType, JID(), id );
   iq.addExtension( new Offline( context, msgs ) );
   m_parent->send( iq, this, context );
 }
Exemplo n.º 13
0
int	main(int ac, char **av)
{
  int	i;

  i = 1;
  while (i < ac)
    {
      if (std::string("-h") == av[i])
	return (usage());
      i++;
    }
  if (ac == 3)
    {
      int u = my_atoi(av[1]);
      int o = my_atoi(av[2]);
      IQ iq(u, o);
      iq.Do_Calc();
      iq.End();
    }
  else if (ac == 4)
    {
      int u = my_atoi(av[1]);
      int o = my_atoi(av[2]);
      int max = my_atoi(av[3]);
      IQ iq(u, o, max);
      iq.Do_Calc();
      iq.End();
    }
  else if (ac == 5)
    {
      int u = my_atoi(av[1]);
      int o = my_atoi(av[2]);
      int min = my_atoi(av[3]);
      int max = my_atoi(av[4]);
      IQ iq(u, o, min, max);
      iq.Do_Calc();
      iq.End();
    }
  else
    {
      std::cerr << "Error in args." << std::endl;
      return (84);
    }
  return (0);
}
Exemplo n.º 14
0
IQReply *Jingle::send(JingleSession *session, Action action, const QList<Content> &contents)
{
	JingleSessionPrivate *d = JingleSessionPrivate::get(session);
	Jingle::Ptr jingle = create(session, action);
	jingle->contents = contents;
	IQ iq(IQ::Set, d->other);
	iq.addExtension(jingle);
	return d->client->send(iq);
}
Exemplo n.º 15
0
  void Registration::createAccount( DataForm* form )
  {
    if( !m_parent || !form )
      return;

    IQ iq( IQ::Set, m_to );
    iq.addExtension( new Query( form ) );
    m_parent->send( iq, this, CreateAccount );
  }
Exemplo n.º 16
0
	void btnSave_OnClick(CCtrlButton *)
	{
		XmlNodeIq iq(_T("set"));
		HXML query = iq << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE));
		HXML storage = query << XCHILDNS(_T("storage"), _T(JABBER_FEAT_MIRANDA_NOTES));
		m_proto->m_notes.SaveXml(storage);
		m_proto->m_ThreadInfo->send(iq);
		EnableControls();
	}
Exemplo n.º 17
0
  void NonSaslAuth::doAuth( const std::string& sid )
  {
    m_sid = sid;
    const std::string& id = m_parent->getID();

    IQ iq( IQ::Get, m_parent->jid().server(), id );
    iq.addExtension( new Query( m_parent->username() ) );
    m_parent->send( iq, this, TrackRequestAuthFields );
  }
Exemplo n.º 18
0
  void Registration::removeAccount()
  {
    if( !m_parent || !m_parent->authed() )
      return;

    IQ iq( IQ::Set, m_to );
    iq.addExtension( new Query( true ) );
    m_parent->send( iq, this, RemoveAccount );
  }
Exemplo n.º 19
0
  void SIManager::acceptSI( const JID& to, const std::string& id, Tag* child1, Tag* child2, const JID& from )
  {
    IQ iq( IQ::Result, to, id );
    iq.addExtension( new SI( child1, child2 ) );
    if( from )
      iq.setFrom( from );

    m_parent->send( iq );
  }
Exemplo n.º 20
0
  void Registration::fetchRegistrationFields()
  {
    if( !m_parent || m_parent->state() != StateConnected )
      return;

    IQ iq( IQ::Get, m_to );
    iq.addExtension( new Query() );
    m_parent->send( iq, this, FetchRegistrationFields );
  }
Exemplo n.º 21
0
void CJabberProto::AddContactToRoster(const TCHAR *jid, const TCHAR *nick, const TCHAR *grpName)
{
	XmlNodeIq iq(_T("set"), SerialNext());
	HXML query = iq << XQUERY(JABBER_FEAT_IQ_ROSTER)
		<< XCHILD(_T("item")) << XATTR(_T("jid"), jid) << XATTR(_T("name"), nick);
	if (grpName)
		query << XCHILD(_T("group"), grpName);
	m_ThreadInfo->send(iq);
}
Exemplo n.º 22
0
static void JabberAdminGet( const TCHAR* to, const char* ns, const char* var, const TCHAR* varVal, JABBER_IQ_PFUNC foo )
{
	int id = JabberSerialNext();
	JabberIqAdd( id, IQ_PROC_NONE, foo );

	XmlNodeIq iq( "get", id, to );
	XmlNode* query = iq.addQuery( ns );
	XmlNode* item = query->addChild( "item" ); item->addAttr( var, varVal );
	JabberSend( jabberThreadInfo->s, iq );
}
Exemplo n.º 23
0
/**
 * Request the leaderboard data from the server.
 */
void XmppClient::SendIqGetBoardList()
{
	glooxwrapper::JID xpartamuppJid(m_xpartamuppId);

	// Send IQ
	glooxwrapper::IQ iq(gloox::IQ::Get, xpartamuppJid);
	iq.addExtension(new BoardListQuery());
	DbgXMPP("SendIqGetBoardList [" << tag_xml(iq) << "]");
	m_client->send(iq);
}
Exemplo n.º 24
0
  void RosterManager::remove( const JID& jid )
  {
    if( !jid )
      return;

    IQ iq( IQ::Set, JID(), m_parent->getID() );
    iq.addExtension( new Query( jid ) );

    m_parent->send( iq, this, RemoveRosterItem );
  }
Exemplo n.º 25
0
  void RosterManager::add( const JID& jid, const std::string& name, const StringList& groups )
  {
    if( !jid )
      return;

    IQ iq( IQ::Set, JID(), m_parent->getID() );
    iq.addExtension( new Query( jid, name, groups) );

    m_parent->send( iq, this, AddRosterItem );
  }
Exemplo n.º 26
0
  void RosterManager::fill()
  {
    if( !m_parent )
      return;

    m_privateXML->requestXML( "roster", XMLNS_ROSTER_DELIMITER, this );
    IQ iq( IQ::Get, JID(), m_parent->getID() );
    iq.addExtension( new Query() );
    m_parent->send( iq, this, RequestRoster );
  }
Exemplo n.º 27
0
  bool Client::bindOperation( const std::string& resource, bool bind )
  {
    if( !( m_streamFeatures & StreamFeatureUnbind ) && m_resourceBound )
      return false;

    IQ iq( IQ::Set, JID(), getID() );
    iq.addExtension( new ResourceBind( resource, bind ) );

    send( iq, this, bind ? CtxResourceBind : CtxResourceUnbind );
    return true;
  }
Exemplo n.º 28
0
void Search::fetchSearchFields( const JID& directory, SearchHandler* sh )
{
    if( !m_parent || !directory || !sh )
        return;

    const std::string& id = m_parent->getID();
    IQ iq( IQ::Get, directory, id );
    iq.addExtension( new Query() );
    m_track[id] = sh;
    m_parent->send( iq, this, FetchSearchFields );
}
Exemplo n.º 29
0
 std::string PrivacyManager::operation( IdType context, const std::string& name )
 {
   const std::string& id = m_parent->getID();
   IQ::IqType iqType = IQ::Set;
   if( context == PLRequestNames || context == PLRequestList )
     iqType = IQ::Get;
   IQ iq( iqType, JID(), id );
   iq.addExtension( new Query( context, name ) );
   m_parent->send( iq, this, context );
   return id;
 }
Exemplo n.º 30
0
HWND __cdecl CJabberProto::SearchAdvanced( HWND hwndDlg )
{
	if ( !m_bJabberOnline || !hwndDlg )
		return 0;	//error

	JabberSearchData * dat=(JabberSearchData *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
	if ( !dat )
		return 0; //error

	// check if server connected (at least one field exists)
	if ( dat->nJSInfCount == 0 )
		return 0;

	// formating request
	BOOL fRequestNotEmpty=FALSE;

	// get server name
	TCHAR szServerName[100];
	GetDlgItemText( hwndDlg, IDC_SERVER, szServerName, SIZEOF( szServerName ));

	// formating query
	int iqId = SerialNext();
	XmlNodeIq iq( _T("set"), iqId, szServerName );
	HXML query = iq << XQUERY( _T("jabber:iq:search"));
	
	if ( m_tszSelectedLang )
		iq << XATTR( _T("xml:lang"), m_tszSelectedLang ); // i'm sure :)

	// next can be 2 cases:
	// Forms: XEP-0055 Example 7
	if ( dat->fSearchRequestIsXForm ) {
		fRequestNotEmpty=TRUE;
		HXML n = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode);
		xmlAddChild( query, n );
		xi.destroyNode( n );
    }
	else { //and Simple fields: XEP-0055 Example 3
		for ( int i=0; i<dat->nJSInfCount; i++ ) {
			TCHAR szFieldValue[100];
			GetWindowText(dat->pJSInf[i].hwndValueItem, szFieldValue, SIZEOF(szFieldValue));
			if ( szFieldValue[0] != _T('\0')) {
				xmlAddChild( query, dat->pJSInf[i].szFieldName, szFieldValue );
				fRequestNotEmpty=TRUE;
	}	}	}

	if ( fRequestNotEmpty ) {
		// register search request result handler
		IqAdd( iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultAdvancedSearch );
		// send request
		m_ThreadInfo->send( iq );
		return ( HWND )iqId;
	}
	return 0;
}