how to add roster with subcription both to someone jid? - xmpp

i hav a social site that for its chat i decide to use XMPP.so i install ejabberd as an XMPP Serve and use Jaxl lib for php to handle ejabberd.for client also i use Strophe to send and recieve stanzas.My problem is that i already have a list of friends that there is no exist on ejabberd server so i want to add item to roster of some one jid from server with subscription Both without any subscription suggestion to that jid.how can i do it?
I dont want use ejabberdctl so adhoc and xmlrpc and mod_* that use command execution is not suitable,i wanna Do it with just stanza.
Is there any way to do it with admin account(jid)?

You can bind ejabberd with mysql and use mod_roster_odbc ,So all of your roster item stores in rosterusers table.
you can directly insert your roster items in this table.

I dont want use ejabberdctl so adhoc and xmlrpc and mod_* that use command execution is not suitable,i wanna Do it with just stanza.
If you don't want to use the available interfaces, you will need to write a custom module for do that with custom stanzas as you want.

Related

How to integrate with OpenFire XMPP server to receive roster info for users?

I need to create small auxiliary server that is part/integrates with OpenFire server in order to get roster for a given user.
I was looking for some plugin/api call that given the user JID to return his contacts and their online status.
All-in-all I may end up changing OpenFire's code but I was hoping that there is a easier solution
All though the links provided by Manasi would work for you. However those links refers to user service plugin which has been depricated by openfire.
They recommend to use REST API plugin.
You'll see list of all plugins here.
You should read about retrieving user roster and their presence .
You could try using the user service plugin of openfire that returns a host of information of the user as well as its rosters.
for documentation click here.
You can get the roster information by this url.

Openfire: Create MUC Room with custom fields

First of all, I'd like to provide some background information: I want to exchange unstructured data between various clients using XMPP. Data sources are supposed to publish their data simply to Mulit-User-Chat rooms (XEP-0045) so that any interested client can register.
XMPP MUC services can have various chat rooms and in order to find the ones my data sources push information to, I'd like to set some custom identification for that room. I figured muc#roominfo_<custom_ident> with some custom value would be great to accomplish that.
For testing purposes I wrote an application that creates a MUC on an XMPP service. Authentication etc. all works fine. I am using Smack to communicate with the XMPP server and to create the room. When I create the room, I am adding a field to the form field I requested before containing my custom information. The MUC is created and accessible. Yet the created custom field is not returned when I perform a disco#info on the room's JID.
I tested this with a local installation of (3.8.2).
I just wonder, if this is an issue of Openfire, that custom form fields (XEP-0068 used here in XEP-0045) are not stored when the MUC is created or if it is just not allowed according to XEP-0045? I read the specification for MUCs and crucially the respective section but couldn't find any evidence that convinced me, that it is explicitly not possible to create such custom form fields for a MUC.
Maybe I just misunderstand something in the specification? Has anyone tried something similar and it's working? If it is an issue of Openfire, I could try a different XMPP server.

How can we make ejabberd server use existing users data, instead of creating a new database for roster?

Suppose a website has already registered users, and has a way for them to add and remove friend from their own friendlist through website.
Now, I want to use ejabberd xmpp server for getting presence information in real-time, but I don't want to have xmpp server to create new database for roster.
Is there any way to configure ejabberd to avoid data duplication on both ejabberd server and website server?
If you don't want to write a custom ejabberd module, you can configure ejabberd to load rosters from a SQL database. If all your rosters modifications are done by your webapp, then from ejabberd point of view the DB is "read only", and you could write a SQL view that has the schema expected by ejabberd but uses the data tables you already have.
See table definitions https://github.com/processone/ejabberd/blob/master/src/odbc/mysql.sql , you need "rosterusers" and "rostergroups" table. Note that this approach has some limitations. Changes in roster won't be seen immediately by connected users unless your application informs ejabberd about that, so ejabberd can inform the clients. For this you probably need to write custom code anyway, and learn about roster push http://xmpp.org/rfcs/rfc3921.html#roster
Or you can write your own custom module to access your roster data.
By default Ejabberd use Mnesia database for Users and Roster etc.
You can configure Ejabberd with external database like SQL SERVER, MySQL, Postgress etc.
You have to configure the ejabberd to use external database (ex: odbc) instead of internal database.
Please see the below to configure Ejabberd with MySQL:
http://iohq.net/index.php?title=Building_an_Ejabberd_Server_with_MySql
After that right a sql script to transfer your existing users in "users" and "rosteruser" table with proper subscription value. Changes in roster done directly in "rosteruser" won't be seen immediately by connected users. To resolve this you can get the friend request confirmation event from application logic (php/asp.net/java) and than add roster through XMPP client. Using this process all roster updation events will be reflected on all connected.

Best way to integrate an XMPP Server into Webapplication

I'm working on a middle size community project, using php and the php framework symfony2 atm.
We are planning to integrate XMPP as a support chat and premium feature for our users. The users will be able to connect via a webclient and also via normal xmpp clients.
So here are my questions:
About the Rosters: I want to have the users from the friends list listed in the users contact list. I know that this can be done with rosters. But how can I implement this on a simple and stable way? Is there a good Server implementation that can get the users roster out of a sql database like pgsql?
What happens on the client when the roster datas are beeing changed while the user is logged in on the xmpp server?
Can I group the users that are listed in the roster of a user?
Which XMPP server project would you recommend for that kind of project?
Thanks for your help in advance!
most existing XMPP servers support all popular DBRMs. So this should be no problem.
probably nothing when you make the changes directly do the database. So have to find a server where you can initiate a roster push to all connected clients. See also the XMPP RFCs for roster updates.
yes, roster groups are a core feature of XMPP.
You can find a list of XMPP servers here: http://xmpp.org/xmpp-software/servers/ You have to check which servers support pgsql and allow you to update the roster and initiate the roster pushes to connected resources.

Candy webclient with Openfire, not working complete

I have set up the Openfire xmpp server and it's running good from a client, but i want to use candy with it to create a chatroom (muc), my settings in openfire work and so there is a conference.blabla.nl, that conference server i can connect with Pandion and Tkabber, i log in and ask what rooms are there or if i want to create one myself, that all go well.
When i connect with candy it only connects as i use a proper login name and pass, but i want it to join or create a chatroom on the muc.
When i login with proper username and pass my screen gets grey, but when i type something to the user logged in at candy there will appear that there are messages but only then, i can't read them in candy...
So to go short, i have candy up and running but shows only information when someone sends something.
Anyone knows about it or have some good tips what could work.
I just want a webclient that people can use with a own chosen name like "guest" or something and then log in to the chatroom.
Any help appreciated.
There are three possible options:
On initialization of Candy, specify autojoin with "true" and in the openfire server specify autojoin bookmarks.
On initialization of Candy, specify autojoin with an array of rooms to autojoin
use the roomPanel Plugin to discover existing rooms and be able to join them.
Btw. we have a support mailinglist as well