0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html."
|
|
8 |
* Initial Contributors:
|
|
9 |
* Nokia Corporation - initial contribution.
|
|
10 |
* Contributors:
|
|
11 |
*
|
|
12 |
* Description:
|
|
13 |
* RCS IM Library - Initial version
|
|
14 |
*
|
|
15 |
*/
|
|
16 |
|
|
17 |
|
|
18 |
#include "chatinterfaces.h"
|
|
19 |
#include "immanagerfactory.h"
|
|
20 |
#include "chatimplfactory.h"
|
|
21 |
#include <QtPlugin>
|
|
22 |
#include <QDir>
|
|
23 |
#include <QLibraryInfo>
|
|
24 |
#include <QPluginLoader>
|
|
25 |
#include <QCoreApplication>
|
|
26 |
|
|
27 |
RcsIMLib::MChatContactManagerIntf* ChatImplFactory::createIMManager(QString protocol)
|
|
28 |
{
|
|
29 |
#ifdef Q_OS_SYMBIAN
|
|
30 |
QDir pluginsDir = QLibraryInfo::location(QLibraryInfo::PluginsPath) + "/IMLIB";
|
|
31 |
#else
|
|
32 |
QDir pluginsDir = QCoreApplication::applicationDirPath() + "/resource/qt/plugins/IMLIB";
|
|
33 |
#endif
|
|
34 |
/* Now doing a dirty implementation.
|
|
35 |
* The real thing to do is parse manifests and compare each plugin for
|
|
36 |
* the protocol string
|
|
37 |
*/
|
|
38 |
IMManagerFactory* imManagerFact=0;
|
|
39 |
foreach (QString fileName, pluginsDir.entryList(QDir::Files))
|
|
40 |
{
|
|
41 |
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
|
|
42 |
QObject *plugin = pluginLoader.instance();
|
|
43 |
if (plugin)
|
|
44 |
{
|
|
45 |
imManagerFact = qobject_cast<IMManagerFactory *>(plugin);
|
|
46 |
if (imManagerFact && imManagerFact->protocol()==protocol)
|
|
47 |
{
|
|
48 |
RcsIMLib::MChatContactManagerIntf* imManager = imManagerFact->createIMManager();
|
|
49 |
//delete imManagerFact;
|
|
50 |
return imManager;
|
|
51 |
}
|
|
52 |
//delete imManagerFact;
|
|
53 |
imManagerFact = 0;
|
|
54 |
}
|
|
55 |
}
|
|
56 |
return 0;
|
|
57 |
}
|
|
58 |
|