source: SMSSender/src/main.cpp @ 44:e087b878bc49

3.0
Last change on this file since 44:e087b878bc49 was 44:e087b878bc49, checked in by Sämy Zehnder <saemy.zehnder@…>, 12 years ago
  • Removed unused libraries from project-files.
  • Fixed segfault on account creation (the default storage for a gateway is assigned at startup now; not in account loading, which was erroneous)
  • Removed versioning from Makefiles
File size: 2.4 KB
Line 
1#include "ui/VCMain/vcmain.h"
2
3#include <QtGui>
4#include <QApplication>
5
6#include <QString>
7#include <QtPlugin>
8
9#include "business/BCSettings.h"
10#include "business/BCAccountManager.h"
11#include "business/BCGatewayManager.h"
12#include "business/BCLibraryLoader.h"
13
14//Q_IMPORT_PLUGIN(interfaces)
15
16void loadGateways() {
17    // TODO: Exception handling
18    QDir gatewayPath(qApp->applicationDirPath());
19    #if defined(Q_OS_WIN)
20        if (gatewayPath.dirName().toLower() == "debug" || gatewayPath.dirName().toLower() == "release")
21            gatewayPath.cdUp();
22    #elif defined(Q_OS_MAC)
23        if (gatewayPath.dirName() == "MacOS") {
24            gatewayPath.cdUp();
25            gatewayPath.cdUp();
26            gatewayPath.cdUp();
27        }
28    #endif
29    gatewayPath.cd("gateways");
30
31    BCGatewayManager::instance()->loadGatewaysFromLibraryPath(gatewayPath);
32}
33
34void loadAccounts() {
35    // TODO: Exception handling
36    BCAccountManager::instance()->readAccountsFromStorage();
37    BCAccountManager::instance()->accountLoadManager()->loadAccounts(BCAccountManager::instance()->getAccountList());
38}
39
40void sendTestSMS(){
41/*    IContact* c = BCContactManager::instance()->getContact(1);
42    QSet<IContact*> recipients;
43    recipients.insert(c);
44
45    IAccount* ac = BCAccountManager::instance()->getAccount(1);
46    ac->sendSMS("testmsg", recipients);*/
47}
48
49int main(int argc, char *argv[]){
50    QApplication a(argc, argv);
51
52    /* Load the translator */
53    QLocale locale = BCSettings::instance()->getLocale();
54
55    QTranslator qtTranslator;
56    qtTranslator.load("qt_" + locale.name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
57    a.installTranslator(&qtTranslator);
58
59    QTranslator myTranslator;
60    if (myTranslator.load(locale.name(), BCSettings::instance()->getLocalePath())){
61        a.installTranslator(&myTranslator);
62    }
63
64    VCMain w;
65    /* Center the window */
66    int scrn = QApplication::desktop()->screenNumber(&w);
67    QRect desk(QApplication::desktop()->availableGeometry(scrn));
68    w.move((desk.width() - w.width()) / 2,
69           (desk.height() - w.height()) / 2);
70
71    /* And finally show it */
72    w.show();
73
74
75    loadGateways();
76
77    foreach (ILibrary* library, BCLibraryLoader::instance()->libraries()) {
78        QTranslator* translator = library->getTranslator(locale);
79        if (!translator->isEmpty()){
80            a.installTranslator(translator);
81        }
82    }
83
84    loadAccounts();
85
86    return a.exec();
87}
Note: See TracBrowser for help on using the repository browser.