summaryrefslogtreecommitdiff
path: root/core/launcher/irserver.cpp
blob: 625cb603d9c8ffdd6ca6bbfda1abccc79ed3c21f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "irserver.h"

#include <qpe/qlibrary.h>
#include <qpe/qpeapplication.h>

#include <qtranslator.h>
#include <stdlib.h>

#include "obexinterface.h"

#include <qdir.h>

IrServer::IrServer( QObject *parent, const char *name )
  : QObject( parent, name )
{
    lib = 0;
    iface = 0;
    QString path = QPEApplication::qpeDir() + "/plugins/obex/";
    QDir dir( path, "lib*.so" );
    QStringList list = dir.entryList();
    QStringList::Iterator it;
    for ( it = list.begin(); it != list.end(); ++it ) {
	QLibrary *trylib = new QLibrary( path + *it );
	//qDebug("trying lib %s", (path + (*it)).latin1() );
	if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
	    lib = trylib;
	    //qDebug("found obex lib" );
	    QString lang = getenv( "LANG" );
	    QTranslator * trans = new QTranslator(qApp);
	    QString type = (*it).left( (*it).find(".") );
	    QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
	    //qDebug("tr fpr obex: %s", tfn.latin1() );
	    if ( trans->load( tfn ))
		qApp->installTranslator( trans );
	    else
		delete trans;

	    break;
	} else {
	    delete lib;
	}
    }
    if ( !lib )
	qDebug("could not load IR plugin" );
}

IrServer::~IrServer()
{
    if ( iface )
	iface->release();
    delete lib;
}