Exemple #1
0
void CSettingsDlgPrivate::setConnections()
{
	bool bResult = false;
	bResult = QObject::connect(dictionariesConfiguration.get(), SIGNAL(dictionarySelected()), 
		m_ptrPublic, SIGNAL(dictionarySelected()));
	logConnection("CSettingsDlgPrivate::setConnections",
		"'dictionariesConfiguration::dictionarySelected' with 'CSettingsDlg::dictionarySelected'", 
		bResult);
  //////////////////////////////////////////////////////////////////////////
  bResult = QObject::connect(substituteConfiguration.get(), SIGNAL(set_selected_consonant_system(const QString &)), 
    gSettings.get(), SLOT(on_set_selected_consonant_system(const QString &)));
  logConnection("CSettingsDlgPrivate::setConnections",
    "'substituteConfiguration::set_selected_consonant_system' with 'Settings::on_set_selected_consonant_system'", 
    bResult);
}
Exemple #2
0
// MAIN
int main(int argc, char **argv) {
   // Local variables
   int pid;
   int port;
   int listenfd;
   int connfd;
   struct sockaddr_in clientAddr;
   socklen_t clientSize = sizeof(clientAddr);
   FILE* logFile;

   // gets port number
   if(argc == 2) {
      port = atoi(argv[1]);
   } else {
      perror("Invalid arguments.");
      exit(1);
   }

   // opens log file
   logFile = fopen("log.txt", "a+");

   // creates listen socket
   listenfd = listenSocket(port);

   // starts listening
   Listen(listenfd, LISTENQUEUE); 

   for ( ; ; ) {
      // accepts a connection
      connfd = Accept(listenfd, (struct sockaddr *)&clientAddr, &clientSize);

      // prints the info
      PrintConnectionInfo(clientAddr);

      // log
      logConnection(logFile, clientAddr);

      // fork
      if((pid = fork()) == 0) {
         // child process closes the listen socket
         close(listenfd);
         
         // process
         process(connfd, clientAddr);
         
         // child process closes the connection
         close(connfd); 

         // prints info of disconnection
         printDisconnectInfo(clientAddr);

         // log
         logDisconnection(logFile, clientAddr);

         // finished execution
         exit(0); 
      }

      // parent process closes the connection with client
      close(connfd);
   }

   // closes log file
   fclose(logFile);

   return(0);
}
XMPP::XMPP(QObject *parent) : QXmppClient(parent),
        m_Hub(NULL),
        m_App(NULL),
        m_Connected(false),
        m_LastError(0),
        m_SendContactWhenAvailable(false),
        m_ConnectionType(OTHER),

        m_Port(27015),
        m_NotificationEnabled(true),
        m_Restarting(false),
        m_VcardManagerConnected(false) {


    m_PauseService = false;

    bool check = connect(this, SIGNAL(messageReceived(QXmppMessage)), this, SLOT(messageReceived(QXmppMessage)));
    Q_ASSERT(check);

    check = connect(&this->rosterManager(), SIGNAL(rosterReceived()), this, SLOT(rosterReceived()));
    Q_ASSERT(check);
    Q_UNUSED(check);


    check = connect(this, SIGNAL(connected()), this, SLOT(logConnection()));
    Q_ASSERT(check);
    Q_UNUSED(check);

    check = connect(this, SIGNAL(error(QXmppClient::Error)), this, SLOT(logConnectionError(QXmppClient::Error)));
    Q_ASSERT(check);


    check = connect(&this->rosterManager(), SIGNAL(presenceChanged(QString,QString)), SLOT(presenceChanged(QString,QString)));
    Q_ASSERT(check);


    // ---------------------------------------------------------------------
    // communication controls
    m_Server = boost::shared_ptr<QTcpServer>(new QTcpServer(this));

    bool ok = connect(m_Server.get(), SIGNAL(newConnection()), this, SLOT(newConnection()));
    Q_ASSERT(ok);
    Q_UNUSED(ok);

    // put the handling of the server into a thread --> avoid blocking the XMPP client while listening a new UI client...
    m_TcpThreadBind = boost::shared_ptr<TcpThreadBind>(new TcpThreadBind());
    m_TcpThreadBind->m_Server = m_Server;
    m_TcpThreadBind->m_Port   = m_Port;



    initOTR();


    // ---------------------------------------------------------------------
    // connection using oauth (PREFERED)

    QSettings settings("Amonchakai", "Hg10");
    if(!settings.value("access_token").value<QString>().isEmpty()) {

        m_GoogleConnect = boost::shared_ptr<GoogleConnectController>(new GoogleConnectController());
        bool check = connect(m_GoogleConnect.get(), SIGNAL(tokenObtained(const QString&)), this, SLOT(readyRestart(const QString &)));
        Q_ASSERT(check);
        Q_UNUSED(check);

        check = connect(m_GoogleConnect.get(), SIGNAL(failedRenew()), this, SLOT(oauth2Restart()));
        Q_ASSERT(check);

        //check = connect(m_GoogleConnect.get(), SIGNAL(failedConnection()), this, SLOT(waitForInternet()));
        //Q_ASSERT(check);

        check = connect(this, SIGNAL(disconnected()), this, SLOT(oauthDisconnected()));
        Q_ASSERT(check);

        oauth2Restart();

    } else {
//void MainWindow::logConnection(QString strConnDesc,bool bResult)
//{
//	QString strDebug = "Connection "+strConnDesc;
//	if (bResult)	strDebug+=" SUCCESS";	else	strDebug+=" FAIL";
//	printLog(eDebugLogLevel,eSlots,strDebug);
//	Q_ASSERT_X(bResult==true,"MainWindow::setConnections",QString("Connect %1").arg(strConnDesc).toAscii());
//}
void MainWindow::setConnections()
{
    bool bResult = false;
    m_ptrStatusBarSignalMapper = new QSignalMapper;
    m_ptrStatusBarSignalMapper->setMapping(m_actionNewConf,QString("New configuration"));
    m_ptrStatusBarSignalMapper->setMapping(m_actionOpenConf,QString("Opening configuration from file"));
    m_ptrStatusBarSignalMapper->setMapping(m_actionSaveConf,QString("Saving configuration to file"));
    m_ptrStatusBarSignalMapper->setMapping(m_actionRefreshConf,QString("Refreshing configuration"));
    bResult = connect(m_actionNewConf, SIGNAL(triggered(bool)) , m_ptrStatusBarSignalMapper, SLOT(map()));
    bResult = connect(m_actionOpenConf, SIGNAL(triggered(bool)) , m_ptrStatusBarSignalMapper, SLOT(map()));
    bResult = connect(m_actionSaveConf, SIGNAL(triggered(bool)) , m_ptrStatusBarSignalMapper, SLOT(map()));
    bResult = connect(m_actionRefreshConf, SIGNAL(triggered(bool)) , m_ptrStatusBarSignalMapper, SLOT(map()));
    bResult = connect(m_ptrStatusBarSignalMapper, SIGNAL(mapped(const QString &)), this, SLOT(onStatusBarMsgChange(const QString &)));


    bResult = connect(m_actionNewConf, SIGNAL(triggered(bool)), CDataThread::getInstance(), SLOT(onNewConf()));
    logConnection("MainWindow::setConnections","'m_actionNewConf::triggered' with 'CDataThread::onNewConf'", bResult);
    bResult = connect(m_actionRefreshConf, SIGNAL(triggered(bool)) ,this, SLOT(onRefreshConf()));
    logConnection("MainWindow::setConnections","'m_actionRefreshConf::triggered' with 'this::onRefreshConf'", bResult);
    bResult = connect(CDataThread::getInstance(), SIGNAL(refreshingFinished()), this, SLOT(onRefreshingFinished()));
    logConnection("MainWindow::setConnections","'CDataThread::getInstance::refreshingFinished' with 'this::onRefreshingFinished'", bResult);
    /////
    bResult = connect(m_actionOpenConf, SIGNAL(triggered(bool)), CDataThread::getInstance(), SLOT(onOpenConf()));
    logConnection("MainWindow::setConnections","'m_actionOpenConf::toggled' with 'CDataThread::onOpenConf'", bResult);
    bResult = connect(m_actionSaveConf, SIGNAL(triggered(bool)), CDataThread::getInstance(), SLOT(onSaveConf()));
    logConnection("MainWindow::setConnections","'m_actionSaveConf::toggled' with 'CDataThread::onSaveConf'", bResult);
    bResult = connect(m_actionSaveAsConf, SIGNAL(triggered(bool)), CDataThread::getInstance(), SLOT(onSaveAsConf()));
    logConnection("MainWindow::setConnections","'m_actionSaveAsConf::toggled' with 'CDataThread::onSaveAsConf'", bResult);
    bResult = connect(m_actionProxySettings, SIGNAL(triggered(bool)) ,this, SLOT(onProxySettings(bool)));
    logConnection("MainWindow::setConnections","'m_actionProxySettings::toggled' with 'this::onProxySettings'", bResult);
    //////////////////////////////////////////////////////////////////////////
    bResult = connect(m_ptrAddComp, SIGNAL(clicked(bool)), CDataThread::getInstance(), SLOT(onAddComp()));
    logConnection("MainWindow::setConnections","'m_ptrAddComp::clicked' with 'CDataThread::onAddComp'", bResult);
    bResult = connect(m_ptrAddShop, SIGNAL(clicked(bool)), CDataThread::getInstance(), SLOT(onAddShop()));
    logConnection("MainWindow::setConnections","'m_ptrAddShop::clicked' with 'CDataThread::onAddShop'", bResult);
    //////////////////////////////////////////////////////////////////////////
    bResult = connect(m_ptCompConfView, SIGNAL(removeShop(int)), CDataThread::getInstance(), SLOT(onRemShop(int)));
    logConnection("MainWindow::setConnections","'m_ptCompConfView::removeShop' with 'CDataThread::onRemShop'", bResult);
    //////////////////////////////////////////////////////////////////////////
    bResult = connect(m_ptCompConfView, SIGNAL(removeComponent(int)), CDataThread::getInstance(), SLOT(onRemComp(int)));
    logConnection("MainWindow::setConnections","'m_ptCompConfView::removeComponent' with 'CDataThread::onRemComp'", bResult);
    ////////////////////////////////////////////////////////////////////////////
    bResult = connect(m_ptCompConfView, SIGNAL(onOpenLink(QModelIndex)) ,
                      CDataThread::getInstance(), SLOT(onOpenLinkInExternalBrowser(QModelIndex)));
    logConnection("MainWindow::setConnections","'m_ptCompConfView::onOpenLink' with 'CDataThread::onOpenLinkInExternalBrowser'", bResult);
    ////////////////////////////////////////////////////////////////////////////
    bResult = connect(m_ptCompConfView, SIGNAL(onOpenSearchPage(QModelIndex)), CDataThread::getInstance(), SLOT(onOpenSearchInExternalBrowser(QModelIndex)));
    logConnection("MainWindow::setConnections","'m_ptCompConfView::onOpenSearchPage' with 'CDataThread::onOpenSerachInExternalBrowser'", bResult);
    ////////////////////////////////////////////////////////////////////////////
    bResult = connect(m_ptCompConfView, SIGNAL(resetFieldCache(QModelIndex)) ,
                      CDataThread::getInstance(), SLOT(onResetFieldCache(QModelIndex)));
    logConnection("MainWindow::setConnections","'m_ptCompConfView::onOpenSearchPage' with 'CDataThread::onOpenSerachInExternalBrowser'", bResult);
    ////////////////////////////////////////////////////////////////////////////
    bResult = connect(CDataThread::getInstance(), SIGNAL(onStatusBarMsg(const QString & )) ,
                      this , SLOT(onStatusBarMsgChange(const QString &)));
    logConnection("MainWindow::setConnections","'CDataThread::getInstance()::onStatusBarMsg' with 'this::onStatusBarMsgChange'", bResult);
    ////////////////////////////////////////////////////////////////////////////
    bResult = connect(CDataThread::getInstance(), SIGNAL(updateRecentFilesAction(const QStringList &)), this , SLOT(onUpdateRecentFileActions(const QStringList &)));
    logConnection("MainWindow::setConnections","'CDataThread::getInstance()::updateRecentFilesAction' with 'this::onUpdateRecentFileActions'", bResult);
}