-rw-r--r-- | core/launcher/irserver.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/core/launcher/irserver.cpp b/core/launcher/irserver.cpp new file mode 100644 index 0000000..b22e064 --- a/dev/null +++ b/core/launcher/irserver.cpp | |||
@@ -0,0 +1,50 @@ | |||
1 | #include "irserver.h" | ||
2 | |||
3 | #include <qpe/qlibrary.h> | ||
4 | #include <qpe/qpeapplication.h> | ||
5 | |||
6 | #include <qtranslator.h> | ||
7 | #include <stdlib.h> | ||
8 | |||
9 | #include "obexinterface.h" | ||
10 | |||
11 | #include <qdir.h> | ||
12 | |||
13 | IrServer::IrServer( QObject *parent, const char *name ) | ||
14 | : QObject( parent, name ) | ||
15 | { | ||
16 | lib = 0; | ||
17 | QString path = QPEApplication::qpeDir() + "/plugins/obex/"; | ||
18 | QDir dir( path, "lib*.so" ); | ||
19 | QStringList list = dir.entryList(); | ||
20 | QStringList::Iterator it; | ||
21 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
22 | ObexInterface *iface = 0; | ||
23 | QLibrary *trylib = new QLibrary( path + *it ); | ||
24 | qDebug("trying lib %s", (path + (*it)).latin1() ); | ||
25 | if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | ||
26 | lib = trylib; | ||
27 | qDebug("found obex lib" ); | ||
28 | QString lang = getenv( "LANG" ); | ||
29 | QTranslator * trans = new QTranslator(qApp); | ||
30 | QString type = (*it).left( (*it).find(".") ); | ||
31 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | ||
32 | qDebug("tr fpr obex: %s", tfn.latin1() ); | ||
33 | if ( trans->load( tfn )) | ||
34 | qApp->installTranslator( trans ); | ||
35 | else | ||
36 | delete trans; | ||
37 | |||
38 | break; | ||
39 | } else { | ||
40 | delete lib; | ||
41 | } | ||
42 | } | ||
43 | if ( !lib ) | ||
44 | qDebug("could not load IR plugin" ); | ||
45 | } | ||
46 | |||
47 | IrServer::~IrServer() | ||
48 | { | ||
49 | delete lib; | ||
50 | } | ||