Reply
Thread Tools
Posts: 22 | Thanked: 9 times | Joined on Jun 2012
#1
I am making an application that will push feeds to nokia N9/N950 home screen. I am stuck at a problem and require help. I am able to generate feeds but rest of the stuff is quite messy.

1- How clicking the feed will open that feed description in my own application.

2- Does meventfeed passes complete url of the feed to uri handler application when it is clicked.

3- How to load GUI when clicking the feed
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#2
Originally Posted by nauman.altaf View Post
1- How clicking the feed will open that feed description in my own application.
There are two ways to enable opening of a feed item in your application:
  1. Pass the URI as an argument in the Exec command specified in the .desktop file, e.g Exec=/path/to/my/binary %U.
  2. Add a DBus service (e.g. com.me.MyApplication) for your application that includes a method for displaying the feed item (e.g. showFeedItem). The method should have DBus method signature "as" (an array of strings, or in Qt terms, QStringList).

The DBus method is better because, as far as I'm aware, passing the URI as an argument to the Exec command only works when there is not an instance of your application already running (unless you allow multiple instances, which is undesirable in most cases). The DBus method allows you to raise an existing instance of your application.

Additionally, using DBus means that you do not necessarily need to add a URI handler, because the event feed itself has a DBus method to add events to it, which allows you to specify a DBus call as the action (whereas MEventFeed uses libcontentaction, which in turn requires you to add the URI handler). Of course, it may well be useful to add the URI handler anyway, for other purposes.

Originally Posted by nauman.altaf View Post
2- Does meventfeed passes complete url of the feed to uri handler application when it is clicked.
Yes, as far I know, though I prefer the DBus method over MEventFeed.

Originally Posted by nauman.altaf View Post
3- How to load GUI when clicking the feed
If you add a DBus service, your DBus method will be called with the URL as the argument. You then need to handle this inside your application to display whatever data you wish. Same applies if you receive the argument via the Exec command.

I recommend adding a DBus service regardless of whether or not you use MEventFeed to add the items, otherwise you will face the problem of not being able to pass an argument to an existing instance of your application.

There is some nice information about using DBus in a Qt application at http://www.developer.nokia.com/Commu...quick_tutorial
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub

Last edited by marxian; 2013-01-30 at 13:05.
 

The Following 6 Users Say Thank You to marxian For This Useful Post:
Posts: 22 | Thanked: 9 times | Joined on Jun 2012
#3
Thanks alot marxian for quite a detailed reply... i have successfully registered DBus servie that is able to generate feeds.. One more thing! when clicking the feed item.

1- How parse url information from array of string provided through 'as' argument. I mean its array not a single string. Single string is easy to deal with but how the url information will be sorted in 'as' and how to fetch it in handler.
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#4
Originally Posted by nauman.altaf View Post
Thanks alot marxian for quite a detailed reply... i have successfully registered DBus servie that is able to generate feeds.. One more thing! when clicking the feed item.

1- How parse url information from array of string provided through 'as' argument. I mean its array not a single string. Single string is easy to deal with but how the url information will be sorted in 'as' and how to fetch it in handler.
The array of strings will in your case only contain a single string, so you simply use the first string in the array (QStringList::first() if you are using Qt). Ensure that it's not empty first.

I should add that it is libcontentaction that requires the argument to be of type "as", otherwise the URI handler will not work with DBus. If you do not need the URI handler, you can use argument of type "s" and accept a single string.
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 

The Following User Says Thank You to marxian For This Useful Post:
Posts: 22 | Thanked: 9 times | Joined on Jun 2012
#5
In my case, i am registering a method in dbus "refresh()". In this method i am using MEventFeed::instance()->addItem(). Buteo Syncfw plugin will call this dbus method at regular intervals to generate feeds. I have one more dbus method "showContent(Constant QString &uri)". My desktop file looks like this

[Desktop Entry]
Type=Application
Name=My Application
MimeType=x-maemo-urischeme/foo
X-Maemo-Service=com.mycompany.service
X-Maemo-Method=com.mycompany.service.showContent
NotShowIn=X-MeeGo;

when i am clicking the feed item, it is not working i.e showContent is not called.

Are these configuration correct? If no please guide me further
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#6
Originally Posted by nauman.altaf View Post
In my case, i am registering a method in dbus "refresh()". In this method i am using MEventFeed::instance()->addItem(). Buteo Syncfw plugin will call this dbus method at regular intervals to generate feeds. I have one more dbus method "showContent(Constant QString &uri)". My desktop file looks like this

[Desktop Entry]
Type=Application
Name=My Application
MimeType=x-maemo-urischeme/foo
X-Maemo-Service=com.mycompany.service
X-Maemo-Method=com.mycompany.service.showContent
NotShowIn=X-MeeGo;

when i am clicking the feed item, it is not working i.e showContent is not called.

Are these configuration correct? If no please guide me further
Your desktop file looks right, though I think it is necessary that the MimeType value have a semi-colon at the end, so it should be

Code:
MimeType=x-maemo-urischeme/foo;
At least in my case, the desktop icon did not show without the semi-colon, which indicates that the desktop file could not be parsed.

If you are using MEventFeed::instance()->addItem(), then your DBus method showContent() should take a QStringList as it's sole argument, instead of a QString. Also, have you created the intreface/adapter files as explained in the wiki page that I linked to earlier?
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 
Posts: 22 | Thanked: 9 times | Joined on Jun 2012
#7
MEventFeed::instance()->addItem() is meventfeed method to generate event feed. What is corresponding DBus method to generate event feed?

i checked com.nokia.home.EventFeed service and it is listing these methods

~ # qdbus com.nokia.home.EventFeed /eventfeed
method qlonglong com.nokia.home.EventFeed.addItem(QVariantMap parameters)
method void com.nokia.home.EventFeed.addRefreshAction(QString action)
signal void com.nokia.home.EventFeed.refreshRequested()
method void com.nokia.home.EventFeed.removeItem(qlonglong id)
method void com.nokia.home.EventFeed.removeItemsBySourceName(Q String sourceName)
method void com.nokia.home.EventFeed.updateItem(qlonglong id, QVariantMap parameters)

My DBus service is working Ok and yes i have used the wrapper generator through qdbusxml2cpp.

In the below link

http://harmattan-dev.nokia.com/docs/...-Bus_call.html

its is stated to use below configurations

MRemoteAction action("com.mycompany.example", "/path", "com.mycompany.example", "refresh");
QDBusInterface interface("com.nokia.home.EventFeed", "/eventfeed", "com.nokia.home.EventFeed", QDBusConnection::sessionBus());
interface.call(QDBus::NoBlock, "addRefreshAction", action.toString());

but at the end it is again using MEventFeed::instance()->addItem()
in the refresh() method. that means MEventFeed::instance()->addItem() is the only way to generate feeds on home screen.
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#8
Originally Posted by nauman.altaf View Post
MEventFeed::instance()->addItem() is meventfeed method to generate event feed. What is corresponding DBus method to generate event feed?

i checked com.nokia.home.EventFeed service and it is listing these methods

~ # qdbus com.nokia.home.EventFeed /eventfeed
method qlonglong com.nokia.home.EventFeed.addItem(QVariantMap parameters)
method void com.nokia.home.EventFeed.addRefreshAction(QString action)
signal void com.nokia.home.EventFeed.refreshRequested()
method void com.nokia.home.EventFeed.removeItem(qlonglong id)
method void com.nokia.home.EventFeed.removeItemsBySourceName(Q String sourceName)
method void com.nokia.home.EventFeed.updateItem(qlonglong id, QVariantMap parameters)

My DBus service is working Ok and yes i have used the wrapper generator through qdbusxml2cpp.

In the below link

http://harmattan-dev.nokia.com/docs/...-Bus_call.html

its is stated to use below configurations

MRemoteAction action("com.mycompany.example", "/path", "com.mycompany.example", "refresh");
QDBusInterface interface("com.nokia.home.EventFeed", "/eventfeed", "com.nokia.home.EventFeed", QDBusConnection::sessionBus());
interface.call(QDBus::NoBlock, "addRefreshAction", action.toString());

but at the end it is again using MEventFeed::instance()->addItem()
in the refresh() method. that means MEventFeed::instance()->addItem() is the only way to generate feeds on home screen.
You can use the com.nokia.home.EventFeed.addItem(QVariantMap parameters) method to add an item to the event feed. Construct a QVariantMap and pass it in the method call:

Code:
QDBusMessage message = QDBusMessage::createMethodCall(
                "com.nokia.home.EventFeed",
                "/eventfeed",
                "com.nokia.home.EventFeed",
                "addItem");

QVariantList args;
QVariantMap itemArgs;
itemArgs.insert("title", "event title");
itemArgs.insert("icon", QString("/path/to/application/icon"));
itemArgs.insert("body", "event description");
itemArgs.insert("imageList", QStringList() << "thumbnail.png");
itemArgs.insert("timestamp", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
itemArgs.insert("video", false);
itemArgs.insert("footer", "event footer");
itemArgs.insert("sourceName", QString("myapplication"));
itemArgs.insert("sourceDisplayName", QString("My Application"));
itemArgs.insert("action", QString("com.me.myApplication / com.me.myApplication showContent %1").arg(URI));

QDBusConnection bus = QDBusConnection::sessionBus();
args.append(itemArgs);
message.setArguments(args);
bus.call(message);
The URI that forms part of the action argument must be base64 encoded, otherwise it won't work. Since the addItem method returns a qlonglong, it's also a good idea to use QDBusConnection::callWithCallback(), so you can check the return value (-1 if unsuccessful).
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 
Posts: 22 | Thanked: 9 times | Joined on Jun 2012
#9
Thanks alot Marxian. It is now working for me. Sorry for late reply as i was not around for sometime. I have one new problem :P

when i click the feed item, it opens my application GUI but the particular feed data is not loaded. Its gets loaded only when i click the button that is meant to do the data loading task. However in Component.onCompleted() i am using the same data loading method as in button.

1) how can load GUI when dbus method com.myapplication.example() is called ? i know one way is to define DBus service but it is giving me the above mentioned problem.
 
Reply


 
Forum Jump


All times are GMT. The time now is 07:56.