示例#1
0
PicaSysTray::PicaSysTray(QObject *parent) :
    QObject(parent)
{
    systrayMenu_ = new QMenu();

    systrayMenu_->addAction(action_center->AboutAct());
    systrayMenu_->addSeparator();
    systrayMenu_->addAction(action_center->ExitAct());

    systray_ = new QSystemTrayIcon(picapica_ico_sit);
    systray_->setContextMenu(systrayMenu_);
    systray_->show();

    connect(systray_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systray_activated(QSystemTrayIcon::ActivationReason)));
    connect(skynet, SIGNAL(BecameSelfAware()), this, SLOT(skynet_became_self_aware()));
    connect(skynet, SIGNAL(LostSelfAwareness()), this, SLOT(skynet_lost_self_awareness()));
}
示例#2
0
void SkyNet::nodethread_connected(QString addr, quint16 port, NodeThread *thread)
{
    if (self_aware)
    {
        emit BecameSelfAware();

    //restore old peer connections, if any
    QList<QByteArray> c2c_peer_ids;

    //load undelivered messages from history
    if (msgqueues.isEmpty())
    {
        History h(config_dbname, Accounts::GetCurrentAccount().id);

        msgqueues = h.GetUndeliveredMessages();
    }

    //load file transfers to be completed
    // sndfilequeues = ...

    QMap<QByteArray, QList<QString> > queues = msgqueues;

    queues.unite(sndfilequeues);

    c2c_peer_ids = queues.uniqueKeys();

    for (int i = 0; i < c2c_peer_ids.size(); i++)
    {
        int ret;
        write_mutex.lock();
        struct PICA_chaninfo *chan = NULL;

        ret = PICA_create_channel(nodelink, (const unsigned char*)c2c_peer_ids[i].constData(), &chan);

        qDebug()<<"restoring channel to "<<c2c_peer_ids[i]<<" ret ="<<ret<<"\n";
        write_mutex.unlock();
    }

    //start timer
    timer_id = startTimer(10000);
    }
}