Thread: mbarcode
View Single Post
Posts: 1,994 | Thanked: 3,342 times | Joined on Jun 2010 @ N900: Battery low. N950: torx 4 re-used once and fine; SIM port torn apart
#503
Quick reply...
Maybe, a local HTML can launch a program, though it depends on browser and its understanding of security.
The problem is, I don't see a way how can mbarcode return string to HTML file: mbarcode doesn't close itself upon reading the barcode, and barcode information is given only to plugins.

However, making a plugin isn't that difficult. Actually, C++ Qt code is quite portable, as Qt is cross-platform.

Theoretically, you could do it this way:
1. local HTML file starts mbarcode (you can try making such an HTML file right now, without studying C++ and Qt);
2. mbarcode scans a barcode;
3. user clicks your plugin in the list (you should have a plugin ready, compiled, workable for this step);
4. the plugin opens HTML file *.html?barcodetype=type&barcodedata=data (again, some C++ code in plugin is needed);
5. The HTML file does whatever you want it to do based on barcodetype and barcodedata (you can test it without a plugin, right now, by typing different values in the URL; it seems it wouldn't be a problem for you to make such an HTML).

I'm attaching code of my workable plugin.

Now, my plugin just puts all the information into one string, and I don't know how to open an HTML file. Ask somebody else about it. Here is some reference documentation:
http://doc.qt.nokia.com/qt-maemo-4.6/

I just have the simplest Qt plugin for mbarcode: two code files, and nothing else. It can be compiled on the N900 itself without problems.

1. Remove .txt from three attached files and unzip one .zip file.
Then you will get two .cpp files, one .xml file and one .so file.
moc.cpp was created by moc and doesn't need to be changed (mostly).
moc.cpp and MBEAN.cpp should be situated in one directory as moc.cpp uses MBEAN.cpp.
.xml file should be moved to /usr/share/mbarcode/plugins/mbean.xml
.so file (ready-to-go, compiled plugin) should be moved to /usr/share/mbarcode/plugins/
2.0. If you don't want to compile, just take the MBEAN.so file and put it into /usr/share/mbarcode/plugins; mbarcode will use it
2.1. To compile, go in X Terminal to the directory where you store moc.cpp and MBEAN.cpp, and run:

g++ -c -pipe -O4 -Wall moc.cpp -o moc.o

g++ -Wall -Wl,-O4 -lQtCore -lQtGui -lQtXml moc.o -o /usr/share/mbarcode/plugins/mbean.so

g++ -Wall -Wl,-O4 -lQtCore -lQtGui -lQtXml moc.o -o /usr/share/mbarcode/plugins/mbean.so -shared


Right now I need to add more information into XML file. In most cases, you can see barcode's country; some countries aren't in the list yet. Later not only EAN-13, but also other codes might be added. The problem is that with time the XML can become too large. The advantage is that you don't need to wait for the developer to add something: you can edit XML by hand.
-------------------------------------------------
For you to make your own plugin:

-lQtXml option is caused by my operations with an XML file; your plugin most likely wouldn't need this.

You can also remove the following lines from MBEAN.cpp:
#include <QtXml/QDomDocument>
#include <QtXml/QDomElement>
#include <QtXml/QDomNode>
#include <QtCore/QStack>

Functions
QStack<QDomNode> findchildren(QDomNode parent, QString data);
QString printstack(QStack<QDomNode> stack, QString data);
can also be removed from class ShowDialogAction.

Don't hesitate to ask questions; somebody will give an answer.
Attached Files
File Type: txt moc.cpp.txt (3.7 KB, 93 views)
File Type: txt MBEAN.cpp.txt (4.6 KB, 96 views)
File Type: txt mbean.xml.txt (4.1 KB, 87 views)
File Type: zip MBEAN.zip (16.1 KB, 91 views)
 

The Following 2 Users Say Thank You to Wikiwide For This Useful Post: