Active Topics

 



Notices


Reply
Thread Tools
Posts: 46 | Thanked: 34 times | Joined on May 2010
#191
Ok, so after my previous post, I started to investigate some things myself.

First of all, I have no idea what i'm doing, so please don't be too harsh if I'm totally wrong, or am trying things that I shouldn't be trying.

So, I had a look at the source of mbarcode-plugin-webrequest

In there, there's a file called "wrsink.cpp", that has this code (i just opened it in textedit on OSX)

Code:
#include "wrsink.h"
#include <mbarcode-qt/plugininterfaces.h>
#include <mbarcode-qt/sinkplugin.h>

#include <QtCore>
#include <QProcess>
#include <QtDBus>
#include <QDesktopServices>

WrSink::WrSink(const PluginInterface *interface) : SinkPlugin(interface) {
    ready = false;
}

QString WrSink::getText()
{
    return "Search with Google";
}

void WrSink::clickAction(QWidget *parentWindow) {
    QString uri = "http://www.google.no/search?q=" + QUrl::toPercentEncoding(barcodeText);
    QDBusInterface *interface = new QDBusInterface("com.nokia.osso_browser","/com/nokia/osso_browser/request","com.nokia.osso_browser");
    interface->call("open_new_window",uri);
}

void WrSink::barcodeAnalysed(QString barcodeType, QString barcodeData) {
    ready = true;
    this->barcodeText = barcodeData;
}

bool WrSink::isReady() {
    return ready;
}
No, am i correct if i assume that if I altered the following, got it compiled, and installed on my n900, it would give me a button that reads "Search Amazon", and would open this link: http://www.amazon.co.uk/s/ref=nb_sb_...=4905524586787 if i scanned the following barcode: 4905524586787?

Code:
#include "wrsink.h"
#include <mbarcode-qt/plugininterfaces.h>
#include <mbarcode-qt/sinkplugin.h>

#include <QtCore>
#include <QProcess>
#include <QtDBus>
#include <QDesktopServices>

WrSink::WrSink(const PluginInterface *interface) : SinkPlugin(interface) {
    ready = false;
}

QString WrSink::getText()
{
    return "Search Amazon";
}

void WrSink::clickAction(QWidget *parentWindow) {
    QString uri = "http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=" + QUrl::toPercentEncoding(barcodeText);
    QDBusInterface *interface = new QDBusInterface("com.nokia.osso_browser","/com/nokia/osso_browser/request","com.nokia.osso_browser");
    interface->call("open_new_window",uri);
}

void WrSink::barcodeAnalysed(QString barcodeType, QString barcodeData) {
    ready = true;
    this->barcodeText = barcodeData;
}

bool WrSink::isReady() {
    return ready;
}
 
Posts: 252 | Thanked: 252 times | Joined on Nov 2009
#192
Originally Posted by edbanger View Post
Since apparently the code to do this is already written (The google plugin uses this method) I would like to ask if someone can publish a tutorial to write a plugin of your own to search the site you would like.
Even better would be if a generic plugin could be written, so you can add sites form within the program.
(Like this: Tap "Add new site", Give it a name how it should appear in the list, add te generic link, and with some special string, mark where the barcode should be inserted in that link.)[/B]
I'm afraid this plugin has not yet been completed because we (lardman and I) who are developing mbarcode have not yet gotten the time to do much with mbarcode lately. The idea is very good, and I plan to make the webrequest-plugin able to do all kinds of searches defined by the user, but right now I've got to focus on my exams and I believe I won't have the time before after the 11th of June. I might have a look at it I get too tired of reading, though

Then my plan is also to write a tutorial on how to make plugins for mbarcode so others might get started more easily. For now I suggest that those who'd like to get started looks at the source code for the webrequest plugin. It is fairly simple and could easily be made into something else.
 
Posts: 252 | Thanked: 252 times | Joined on Nov 2009
#193
Originally Posted by edbanger View Post
No, am i correct if i assume that if I altered the following, got it compiled, and installed on my n900, it would give me a button that reads "Search Amazon", and would open this link: http://www.amazon.co.uk/s/ref=nb_sb_...=4905524586787 if i scanned the following barcode: 4905524586787?
Oops, sorry. I didn't see your second post before I wrote mine.

You are correct, it would open that link if you compiled it like that (and packaged it or installed it). But making a plugin for each search provider is probably not a good choice. I'll try to make one plugin take care of all search providers, with an easy option to create custom searches as well.

Would it be sufficient if you could click a button and then select the search provider of choice?
 
Posts: 46 | Thanked: 34 times | Joined on May 2010
#194
Originally Posted by dragly View Post
Oops, sorry. I didn't see your second post before I wrote mine.

You are correct, it would open that link if you compiled it like that (and packaged it or installed it). But making a plugin for each search provider is probably not a good choice. I'll try to make one plugin take care of all search providers, with an easy option to create custom searches as well.

Would it be sufficient if you could click a button and then select the search provider of choice?
Yes, I know that isn't a wise choice, but is was just trying to understand how the plugin works (I've never written a line of code in my life).

Of course a plugin with te mayor search providers pre-listed + a custom search option.
I have always thought of it like this:

The button that performs the google search right now would show a list of all available search engines. These search engines, and the links needed for them are eather editable from the program itsself, or from a config file somewhere on the flash memory that i can edit in something like leafpad.

Thanks for al the hard work you guys have already put in for people like me, who want all the cool stuff, but can't code it themselves.
 
Posts: 252 | Thanked: 252 times | Joined on Nov 2009
#195
Alright, I decided to take some time last night and make some updates to the plugin after all I just got some ideas about how to do it pretty quickly, so I thought I should give it a shot.

And here we are. It now has a list of default providers and you are able to edit them through the top menu. You can also add new, custom search providers. Just update to the newest version of mbarcode-plugin-webrequest in App Manager and give it a try.

If you'd like to edit the config file directly, you'll find this under
Code:
/home/user/.config/mbarcode/webrequest-plugin.conf
However, keep in mind that if you edit the config file directly, you'll have to update the numbers next to the providers so that they appear in the same ordered fashion as when the application creates it. This is a downside to the config files Qt creates which I don't know how to get around, but I guess most people will just edit them in the application itself.

I believe I've cleared out all bugs for now, but give me a heads up if something is wrong. Hope you find the plugin a bit more useful now Have fun with it!

For those of you missing UTF-8 support, I'm uploading a new version of mbarcode which hopefully will support UTF-8 now. It has been lying around for a while now and has just not been uploaded yet.
 

The Following 3 Users Say Thank You to dragly For This Useful Post:
Posts: 79 | Thanked: 21 times | Joined on Sep 2007
#196
Sounds really great, but don't risk your exam! :-)
 
Posts: 252 | Thanked: 252 times | Joined on Nov 2009
#197
Originally Posted by tvogel View Post
Sounds really great, but don't risk your exam! :-)
Thanks for the reminder I better return back to my books now
 
Posts: 18 | Thanked: 5 times | Joined on Jul 2009 @ Boston Harbor
#198
I hate to sound like a downer(cow?) but I've been trying to hack up the code in mbarcode for a little while due to a launch problem I have with the downloaded package. I'm using camera 3.5 and mbarcode 0.0.8-0 with fair process but I have to manually launch mbarcode via cmdline. Why is it so difficult to make an application shortcut in hildon? I've tried forcing to start with @prefix@/usr/bin/mbarcode and I still can't get anywhere with it.

Program works just fine but the launcher is broken.
 
Posts: 46 | Thanked: 34 times | Joined on May 2010
#199
I believe I've cleared out all bugs for now, but give me a heads up if something is wrong. Hope you find the plugin a bit more useful now Have fun with it!
Well, this was fast! Thanks for implementing exactly what I was looking for!

One small downside however: The first scan I did, everything worked fine. The barcode info was added to the search link for the different providers, and I could click one, and it would work.

However, when I do a new scan, the code from the first one still remains in the search link, so my results always show the product from the first scan. Closing, and then reopening mBarcode does not fix this.
 
Posts: 252 | Thanked: 252 times | Joined on Nov 2009
#200
Originally Posted by edbanger View Post
Well, this was fast! Thanks for implementing exactly what I was looking for!

One small downside however: The first scan I did, everything worked fine. The barcode info was added to the search link for the different providers, and I could click one, and it would work.

However, when I do a new scan, the code from the first one still remains in the search link, so my results always show the product from the first scan. Closing, and then reopening mBarcode does not fix this.
I experienced the same bug too and was hoping noone used that version before I got to fix it :-p It is the default search providers that have been overwritten with an URL containing the first barcode you searched for.

To fix this you just have to update to the newest version of the plugin and remove the config file by running this command in terminal:
Code:
rm /home/user/.config/mbarcode/webrequest-plugin.conf
The next time you run the application everything should be as it is supposed to.
 

The Following User Says Thank You to dragly For This Useful Post:
Reply

Tags
barcode, camera, mbarcode


 
Forum Jump


All times are GMT. The time now is 21:48.