Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

irserver.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #include "irserver.h"
00022 #include "obexinterface.h"
00023 
00024 /* OPIE */
00025 #include <opie2/odebug.h>
00026 #include <qtopia/qlibrary.h>
00027 #include <qtopia/qpeapplication.h>
00028 
00029 /* QT */
00030 #include <qdir.h>
00031 
00032 IrServer::IrServer( QObject *parent, const char *name )
00033   : QObject( parent, name ), obexIface(0)
00034 {
00035     lib = 0;
00036     obexIface = 0;
00037     QString path = QPEApplication::qpeDir() + "plugins/obex/";
00038 #ifdef Q_OS_MACX
00039     QDir dir( path, "lib*.dylib" );
00040 #else
00041     QDir dir( path, "lib*.so" );
00042 #endif /* Q_OS_MACX */
00043     QStringList list = dir.entryList();
00044     QStringList::Iterator it;
00045     for ( it = list.begin(); it != list.end(); ++it ) {
00046         QLibrary *trylib = new QLibrary( path + *it );
00047     //odebug << "trying lib " << (path + (*it)) << "" << oendl;
00048         if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&obexIface ) == QS_OK ) {
00049             lib = trylib;
00050         //odebug << "found obex lib" << oendl;
00051             QString lang = getenv( "LANG" );
00052             QTranslator * trans = new QTranslator(qApp);
00053             QString type = (*it).left( (*it).find(".") );
00054             QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm";
00055         //odebug << "tr fpr obex: " << tfn << "" << oendl;
00056             if ( trans->load( tfn ))
00057                 qApp->installTranslator( trans );
00058             else
00059                 delete trans;
00060 
00061             break;
00062         } else {
00063             delete lib;
00064         }
00065     }
00066     if ( !lib )
00067     odebug << "could not load IR plugin" << oendl;
00068 }
00069 
00070 IrServer::~IrServer()
00071 {
00072     if ( obexIface )
00073         obexIface->release();
00074     delete lib;
00075 }
00076 

Generated on Sat Nov 5 16:15:30 2005 for OPIE by  doxygen 1.4.2