Example #1
0
void SensorSystem::setShutdown (bool setting) {

	if (setting) {
		if (notShutdown) {
			long i = 0;
			while (i < numContacts) {
				MoverPtr mover = (MoverPtr)ObjectManager->get(contacts[i] & 0x7FFF);
				if (contacts[i] & VISUAL_CONTACT_FLAG) {
					master->removeContact(this, mover);
					i++;
					}
				else
					removeContact(i);
			}
		}
//		clearContacts();
		notShutdown = false;
		}
	else {
		if (!notShutdown)
			for (long i = 0; i < numContacts; i++) {
				MoverPtr mover = (MoverPtr)ObjectManager->get(contacts[i] & 0x7FFF);
				if (contacts[i] & VISUAL_CONTACT_FLAG)
					master->addContact(this, mover, i, CONTACT_VISUAL);
				else
					master->addContact(this, mover, i, getSensorQuality());
			}
		notShutdown = true;
	}
}
Example #2
0
ClientWindow::ClientWindow(ClientController* c, QWidget *parent) :
    client(c), QWidget(parent), ui(new Ui::ClientWindow)
{
    ui->setupUi(this);
    connect(ui->pushButtonWindowClientInsert, SIGNAL(clicked()), this, SLOT(insertContact()));
    connect(ui->pushButtonWindowClientRemove, SIGNAL(clicked()), this, SLOT(removeContact()));
}
Example #3
0
long SensorSystem::scanMover (Mover* mover) {

	//---------------------------------------------------------------------
	// For now, I DO NOT return the largest contact. This should be
	// okay, since it'll just get caught during the next normal update next
	// frame.

	if (!enabled())
		return(0);

	if (mover->getExists() && (mover->getTeamId() != owner->getTeamId())) {
		long contactStatus = calcContactStatus(mover);
		if (isContact(mover)) 
		{
			if (contactStatus == CONTACT_NONE)
				removeContact(mover);
			else
			{
				modifyContact(mover, contactStatus == CONTACT_VISUAL ? true : false);
				//getLargest(currentLargest,mover,contactStatus);
			}
		}
		else 
		{
			if (contactStatus != CONTACT_NONE) 
			{
				addContact(mover, contactStatus == CONTACT_VISUAL ? true : false);
				//getLargest(currentLargest,mover,contactStatus);
				totalContacts++;
			}
		}
	}
	return(0);
}
Example #4
0
AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent), ui(new Ui::AddressBook)
{
    ui->setupUi(this);

    ui->nameLine->setReadOnly(true);
    ui->addressText->setReadOnly(true);
    ui->submitButton->hide();
    ui->cancelButton->hide();
    ui->nextButton->setEnabled(false);
    ui->previousButton->setEnabled(false);
    ui->editButton->setEnabled(false);
    ui->removeButton->setEnabled(false);

    connect(ui->addButton, SIGNAL(clicked()), this,
                SLOT(addContact()));
    connect(ui->submitButton, SIGNAL(clicked()), this,
                SLOT(submitContact()));
    connect(ui->cancelButton, SIGNAL(clicked()), this,
                SLOT(cancel()));
    connect(ui->nextButton, SIGNAL(clicked()), this,
                SLOT(next()));
    connect(ui->previousButton, SIGNAL(clicked()), this,
                SLOT(previous()));
    connect(ui->editButton, SIGNAL(clicked()), this,
                SLOT(editContact()));
    connect(ui->removeButton, SIGNAL(clicked()), this,
                SLOT(removeContact()));
//! [signal slot]
    connect(ui->findButton, SIGNAL(clicked()), this,
                SLOT(findContact()));
//! [signal slot]

    setWindowTitle(tr("Simple Address Book"));
}
Example #5
0
void ContactListGroup::clearGroup()
{
	foreach(PsiContact* contact, contacts_)
		removeContact(contact);
	qDeleteAll(contacts_);
	contacts_.clear();
}
Example #6
0
void JabberRoomChat::participantRemoved(const QString &id)
{
    auto jid = Jid::parse(id);
    auto contact = m_contactManager->byId(m_chat.chatAccount(), id, ActionReturnNull);

    auto details = static_cast<ChatDetailsRoom *>(m_chat.details());
    details->removeContact(contact);
}
Example #7
0
void Roster::removeContact(const Contact &contact) const
{
	if (!contact)
		return;

	auto service = rosterService(contact);
	if (service)
	{
		service->removeContact(contact);
	}
}
Example #8
0
	void TriggerNode::setEnabled(bool s) {
		if (Node::isEnabled() == s) return;
		Node::setEnabled(s);
		changed = true;
		if (Node::isEnabled() == false) {
			while (contacts.count()) {
				contacts[0].removeContact(this);
				removeContact(&contacts[0]);
			}
		}
	}
Example #9
0
void RosterDBManager::removeGroup(QString gjid)
{
    QSqlQuery query(db);

    query.prepare("delete from participants where gjid=:gjid");
    query.bindValue(":gjid",gjid);

    query.exec();

    removeContact(gjid);
}
Example #10
0
bool SSIManager::removeContact( const QString &contact )
{
    Oscar::SSI ct = findContact( contact );

    if ( ct.isValid() && removeContact( ct ) )
        return true;
    else
        kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Contact " << contact << " not found." << endl;

    return false;
}
Example #11
0
//---------------------------------------------------------------------------
long SensorSystem::scanBattlefield (void) 
{
	//NOW returns size of largest contact!
	long currentLargest = -1;
	
	if (!owner)
		Fatal(0, " Sensor has no owner ");

	if (!master)
		Fatal(0, " Sensor has no master ");

	if ((masterIndex == -1) || (range < 0.0))
		return(0);

	long numNewContacts = 0;

	long numMovers = ObjectManager->getNumMovers();
	for (long i = 0; i < numMovers; i++) 
	{
		MoverPtr mover = (MoverPtr)ObjectManager->getMover(i);
		if (mover->getExists() && (mover->getTeamId() != owner->getTeamId())) 
		{
			long contactStatus = calcContactStatus(mover);
			if (isContact(mover)) 
			{
				if (contactStatus == CONTACT_NONE)
					removeContact(mover);
				else
				{
					modifyContact(mover, contactStatus == CONTACT_VISUAL ? true : false);
					getLargest(currentLargest,mover,contactStatus);
				}
			}
			else 
			{
				if (contactStatus != CONTACT_NONE) 
				{
					addContact(mover, contactStatus == CONTACT_VISUAL ? true : false);
					getLargest(currentLargest,mover,contactStatus);
					numNewContacts++;
				}
			}
		}
	}

	totalContacts += numNewContacts;
	
	return(currentLargest);
}
Example #12
0
void
ContactPanel::onContactDeletionRequested()
{
  QItemSelectionModel* selectionModel = ui->ContactList->selectionModel();
  QModelIndexList selectedList = selectionModel->selectedIndexes();

  for (QModelIndexList::iterator it = selectedList.begin(); it != selectedList.end(); it++) {
    QString alias =  m_contactListModel->data(*it, Qt::DisplayRole).toString();
    for (int i = 0; i < m_contactAliasList.size(); i++)
      if (m_contactAliasList[i] == alias) {
        emit removeContact(m_contactIdList[i]);
        return;
      }
  }
}
Example #13
0
void ContactModel::addBot(MAGNORMOBOT *bot)
{
	if (conduits.contains(bot)) {
		qWarning("ContactModel is already tracking %p\n", bot);
		return;
	}
	connect(bot, SIGNAL(contactPresenceUpdated(QString)), SLOT(updateContactPresence(QString)));
    connect(bot, SIGNAL(contactAdded(QString)), SLOT(addContact(QString)));
    connect(bot, SIGNAL(contactUpdated(QString)), SLOT(updateContact(QString)));
    connect(bot, SIGNAL(contactRemoved(QString)), SLOT(removeContact(QString)));
	connect(bot, SIGNAL(contactListReceived()), SLOT(receiveContactList()));
	connect(bot, SIGNAL(disconnected()), SLOT(botDisconnected()), Qt::QueuedConnection);
	connect(bot, SIGNAL(destroyed()), SLOT(botDestroyed()));
    refreshContacts(bot);
}
Example #14
0
SipUri SipUriList::getPriorContact( void )
{
	QValueList<SipUri>::Iterator it;
	SipUri uri = urilist.first();
	int q = 0;
	for( it = urilist.begin(); it != urilist.end(); ++it ) {
		SipUri contact = SipUri(*it);
		if( q < contact.getPrior().toInt() ) {
			q = contact.getPrior().toInt();
			uri = contact;
		}
	}
	removeContact( uri );
	
	return uri;
}
Example #15
0
void JabberRoomChat::participantChanged(const QString &id)
{
    auto jid = Jid::parse(id);
    auto contact = m_contactManager->byId(m_chat.chatAccount(), id, ActionCreateAndAdd);
    auto buddy = m_buddyManager->byContact(contact, ActionCreateAndAdd);
    buddy.setDisplay(jid.resource());
    buddy.setTemporary(true);

    auto status = m_presenceService->presenceToStatus(m_room->participantPresence(id));
    contact.setCurrentStatus(status);

    auto details = static_cast<ChatDetailsRoom *>(m_chat.details());
    if (status.isDisconnected())
        details->removeContact(contact);
    else
        details->addContact(contact);
}
Example #16
0
void ContactListModel::Private::commit()
{
    SLOW_TIMER(100);

    commitTimerStartTime = QDateTime();

    commitTimer->stop();
    if (operationQueue.isEmpty())
        return;

    QHashIterator<PsiContact*, int> it(operationQueue);

    QList<PsiContact*> contactsForAdding;
    QList<PsiContact*> contactsForUpdate;


    while (it.hasNext()) {
        it.next();
        PsiContact *contact = it.key();

        int operations = simplifiedOperationList(it.value());
        if (operations & AddContact) {
            Q_ASSERT(!monitoredContacts.contains(contact));
            if (monitoredContacts.contains(contact))
                continue;

            contactsForAdding << contact;

        }
        if (operations & RemoveContact)
            Q_ASSERT(false);
        if (operations & UpdateContact)
            contactsForUpdate << contact;
        if (operations & ContactGroupsChanged) {
            removeContact(contact);
            if (!contactsForAdding.contains(contact)) {
                contactsForAdding << contact;
            }
        }
    }

    addContacts(contactsForAdding);
    updateContacts(contactsForUpdate);
    operationQueue.clear();
}
Example #17
0
void SensorSystem::updateContacts (void) {

	if ((masterIndex == -1) || (range < 0.0))
		return;

	if (!enabled()) {
		clearContacts();
		return;
	}

	//---------------------------------------------------------------------
	// If we've already scanned this frame, don't bother updating contacts.
	// Otherwise, update contacts...
	if (scenarioTime == lastScanUpdate)
		return;

	long i = 0;
	while (i < numContacts) 
	{
		MoverPtr contact = (MoverPtr)ObjectManager->get(contacts[i] & 0x7FFF);
		long contactStatus = calcContactStatus(contact);
		if (contactStatus == CONTACT_NONE)
			removeContact(i);
		else 
		{
			contacts[i] =  contact->getHandle();
			if (contactStatus == CONTACT_VISUAL)
				contacts[i] |= 0x8000;
			modifyContact(contact, contactStatus == CONTACT_VISUAL);
			
/*			if (teamContactStatus < contactStatus) {
				//--------------------------------------------------
				// Better sensor info, so update the team sensors...
				contactInfo->contactStatus[owner->getTeamId()] = contactStatus;
				contactInfo->teamSpotter[owner->getTeamId()] = (unsigned char)owner->getHandle();
			}
*/			i++;
		}
	}
}
Example #18
0
void MultitouchPlugin::updateContact(TouchContact &c)
{
    //update mouse, but only if this is the one we used as a mouse input
    if (_mode == MOUSE && c.id == _mouseID)
    {
        cover->handleMouseEvent(osgGA::GUIEventAdapter::DRAG, static_cast<int>(c.x), static_cast<int>(cover->frontWindowVerticalSize - c.y));
    }

    // update contact
    std::list<TouchContact>::iterator it;
    for (it = _contacts.begin(); it != _contacts.end(); it++)
    {
        if (it->id == c.id)
        {
            (*it) = c;
            return;
        }
    }

    cerr << "EXCEPTION @MultitouchPlugin::changedContact: \n contact ID = " << c.id << " could not be updated" << endl;
    cerr << "removing and re-adding contact..." << endl;
    removeContact(c);
    addContact(c);
}
Example #19
0
AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent)
{
    QLabel *nameLabel = new QLabel(tr("Name:"));
    nameLine = new QLineEdit;
    nameLine->setReadOnly(true);

    QLabel *addressLabel = new QLabel(tr("Address:"));
    addressText = new QTextEdit;
    addressText->setReadOnly(true);

    addButton = new QPushButton(tr("&Add"));

    editButton = new QPushButton(tr("&Edit"));
    editButton->setEnabled(false);
    removeButton = new QPushButton(tr("&Remove"));
    removeButton->setEnabled(false);
    findButton = new QPushButton(tr("&Find"));
    findButton->setEnabled(false);
    submitButton = new QPushButton(tr("&Submit"));
    submitButton->hide();
    cancelButton = new QPushButton(tr("&Cancel"));
    cancelButton->hide();

    nextButton = new QPushButton(tr("&Next"));
    nextButton->setEnabled(false);
    previousButton = new QPushButton(tr("&Previous"));
    previousButton->setEnabled(false);

    loadButton = new QPushButton(tr("&Load..."));
//! [tooltip 1]    
    loadButton->setToolTip(tr("Load contacts from a file"));
//! [tooltip 1]        
    saveButton = new QPushButton(tr("&Save..."));
//! [tooltip 2]
    saveButton->setToolTip(tr("Save contacts to a file"));
//! [tooltip 2]
    saveButton->setEnabled(false);

    dialog = new FindDialog;

    connect(addButton, SIGNAL(clicked()), this, SLOT(addContact()));
    connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact()));
    connect(editButton, SIGNAL(clicked()), this, SLOT(editContact()));
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
    connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact()));
    connect(findButton, SIGNAL(clicked()), this, SLOT(findContact()));
    connect(nextButton, SIGNAL(clicked()), this, SLOT(next()));
    connect(previousButton, SIGNAL(clicked()), this, SLOT(previous()));
    connect(loadButton, SIGNAL(clicked()), this, SLOT(loadFromFile()));
    connect(saveButton, SIGNAL(clicked()), this, SLOT(saveToFile()));
    
    QVBoxLayout *buttonLayout1 = new QVBoxLayout;
    buttonLayout1->addWidget(addButton);
    buttonLayout1->addWidget(editButton);
    buttonLayout1->addWidget(removeButton);
    buttonLayout1->addWidget(findButton);
    buttonLayout1->addWidget(submitButton);
    buttonLayout1->addWidget(cancelButton);
    buttonLayout1->addWidget(loadButton);
    buttonLayout1->addWidget(saveButton);
    buttonLayout1->addStretch();

    QHBoxLayout *buttonLayout2 = new QHBoxLayout;
    buttonLayout2->addWidget(previousButton);
    buttonLayout2->addWidget(nextButton);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(nameLabel, 0, 0);
    mainLayout->addWidget(nameLine, 0, 1);
    mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
    mainLayout->addWidget(addressText, 1, 1);
    mainLayout->addLayout(buttonLayout1, 1, 2);
    mainLayout->addLayout(buttonLayout2, 2, 1);

    setLayout(mainLayout);
    setWindowTitle(tr("Simple Address Book"));
}
Example #20
0
AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent)
{
    QLabel *nameLabel = new QLabel(tr("Name:"));
    nameLine = new QLineEdit;
    nameLine->setReadOnly(true);

    QLabel *addressLabel = new QLabel(tr("Address:"));
    addressText = new QTextEdit;
    addressText->setReadOnly(true);

    addButton = new QPushButton(tr("&Add"));
//! [edit and remove buttons] 
    editButton = new QPushButton(tr("&Edit"));
    editButton->setEnabled(false);
    removeButton = new QPushButton(tr("&Remove"));
    removeButton->setEnabled(false);
//! [edit and remove buttons] 
    submitButton = new QPushButton(tr("&Submit"));
    submitButton->hide();
    cancelButton = new QPushButton(tr("&Cancel"));
    cancelButton->hide();
    
    nextButton = new QPushButton(tr("&Next"));
    nextButton->setEnabled(false);
    previousButton = new QPushButton(tr("&Previous"));
    previousButton->setEnabled(false);

    connect(addButton, SIGNAL(clicked()), this, SLOT(addContact()));
    connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact()));
//! [connecting edit and remove] 
    connect(editButton, SIGNAL(clicked()), this, SLOT(editContact()));
    connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact()));
//! [connecting edit and remove] 
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
    connect(nextButton, SIGNAL(clicked()), this, SLOT(next()));
    connect(previousButton, SIGNAL(clicked()), this, SLOT(previous()));

    QVBoxLayout *buttonLayout1 = new QVBoxLayout;
    buttonLayout1->addWidget(addButton);
//! [adding edit and remove to the layout]     
    buttonLayout1->addWidget(editButton);
    buttonLayout1->addWidget(removeButton);
//! [adding edit and remove to the layout]         
    buttonLayout1->addWidget(submitButton);
    buttonLayout1->addWidget(cancelButton);
    buttonLayout1->addStretch();

    QHBoxLayout *buttonLayout2 = new QHBoxLayout;
    buttonLayout2->addWidget(previousButton);
    buttonLayout2->addWidget(nextButton);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(nameLabel, 0, 0);
    mainLayout->addWidget(nameLine, 0, 1);
    mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
    mainLayout->addWidget(addressText, 1, 1);
    mainLayout->addLayout(buttonLayout1, 1, 2);
    mainLayout->addLayout(buttonLayout2, 2, 1);

    setLayout(mainLayout);
    setWindowTitle(tr("Simple Address Book"));
}
Example #21
0
void rosterListView::removeContact_helper()
{
    QString bareJid = selectedBareJid();
    if(!bareJid.isEmpty())
        emit removeContact(bareJid);
}
Example #22
0
Xmpp_client::Xmpp_client(QString a_login, QString a_password, int a_xmpp_client_port, QObject *parent) : m_login(a_login), m_password(a_password), m_xmpp_client_port(a_xmpp_client_port), QXmppClient(parent)
{
    bool check;
    Q_UNUSED(check);

    m_capabilitiesCache = new capabilitiesCache(this);
    m_vCardCache = new vCardCache(this);

    qDebug() << "Xmpp_client::Xmpp_client !!!";

    QXmppLogger::getLogger()->setLoggingType(QXmppLogger::SignalLogging);


    transfer_manager = new QXmppTransferManager;
    this->addExtension (transfer_manager);


    // uncomment one of the following if you only want to use a specific transfer method:
    //
     //transfer_manager->setSupportedMethods(QXmppTransferJob::InBandMethod);
    // manager->setSupportedMethods(QXmppTransferJob::SocksMethod);
     transfer_manager->setProxy("proxy.nodecast.net");
     transfer_manager->setSupportedMethods(QXmppTransferJob::InBandMethod);

     muc_manager = new QXmppMucManager;
     this->addExtension(muc_manager);



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


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


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


     check = connect(this, SIGNAL(messageReceived(const QXmppMessage&)),
           SLOT(messageReceived(const QXmppMessage&)));
       Q_ASSERT(check);
       Q_UNUSED(check);

    check = connect(this, SIGNAL(presenceReceived(const QXmppPresence&)),
                    SLOT(presenceReceived(const QXmppPresence&)));



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


   // check = connect(&m_xmppClient, SIGNAL(connected()), SLOT(addAccountToCache()));
  //  Q_ASSERT(check);


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


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


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



    check = connect(transfer_manager, SIGNAL(fileReceived(QXmppTransferJob*)),
                             SLOT(file_received(QXmppTransferJob*)));
    Q_ASSERT(check);


    check = connect(transfer_manager, SIGNAL(jobFinished(QXmppTransferJob*)),
                             SLOT(job_finished(QXmppTransferJob*)));
    Q_ASSERT(check);


    check = connect(&this->vCardManager(),
                    SIGNAL(vCardReceived(QXmppVCardIq)), m_vCardCache,
                    SLOT(vCardReceived(QXmppVCardIq)));
    Q_ASSERT(check);

    check = connect(m_vCardCache,
                    SIGNAL(vCardReadyToUse(QString)),
                    SLOT(updateVCard(QString)));
    Q_ASSERT(check);




    check = connect(QXmppLogger::getLogger(),
            SIGNAL(message(QXmppLogger::MessageType,QString)),
            &m_consoleDlg,
            SLOT(message(QXmppLogger::MessageType,QString)));
    Q_ASSERT(check);




    //this->logger()->setLoggingType(QXmppLogger::StdoutLogging);

    //this->logger()->setLoggingType(QXmppLogger::FileLogging);


    m_rosterItemSortFilterModel = new rosterItemSortFilterProxyModel(this);
    m_rosterItemModel = new rosterItemModel(this);
    roster = new Ui::Roster;
    roster_widget= new QWidget;
    roster->setupUi(roster_widget);
    layoutRoster = new QVBoxLayout;
    layoutRoster->addWidget(&m_statusWidget);
    layoutRoster->addWidget(roster_widget);

    m_stacked_tab_chat = new QStackedWidget;

    vRosterSplitter = new QSplitter(Qt::Horizontal);
    groupBoxContact = new QGroupBox;
    groupBoxContact->setLayout(layoutRoster);

    vRosterSplitter->addWidget(groupBoxContact);
    vRosterSplitter->addWidget(m_stacked_tab_chat);

    check = connect(roster->lineEdit_filter, SIGNAL(textChanged(QString)),
                    this, SLOT(filterChanged(QString)));
    Q_ASSERT(check);


    m_rosterItemSortFilterModel->setSourceModel(m_rosterItemModel);
    roster->listView->setModel(m_rosterItemSortFilterModel);
    m_rosterItemSortFilterModel->sort(0);


    connect(roster->listView->selectionModel(),
            SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(rosterItemSelectionChanged(QItemSelection)));




    rosterItemDelegate *delegate = new rosterItemDelegate();
    roster->listView->setItemDelegate(delegate);
    roster->verticalLayout->insertWidget(0, &m_statusWidget);


    check = connect(&m_statusWidget, SIGNAL(statusTextChanged(QString)),
                    SLOT(statusTextChanged(QString)));
    Q_ASSERT(check);
    check = connect(&m_statusWidget, SIGNAL(presenceTypeChanged(QXmppPresence::Type)),
                    SLOT(presenceTypeChanged(QXmppPresence::Type)));
    Q_ASSERT(check);
    check = connect(&m_statusWidget,
                    SIGNAL(presenceStatusTypeChanged(QXmppPresence::AvailableStatusType)),
                    SLOT(presenceStatusTypeChanged(QXmppPresence::AvailableStatusType)));
    Q_ASSERT(check);
    check = connect(&m_statusWidget,
                    SIGNAL(avatarChanged(QImage)),
                    SLOT(avatarChanged(QImage)));
    Q_ASSERT(check);


    check = connect(roster->listView, SIGNAL(showProfile(QString)),
                    this, SLOT(showProfile(QString)));
    Q_ASSERT(check);

    check = connect(roster->listView, SIGNAL(removeContact(QString)),
                    this, SLOT(action_removeContact(QString)));
    Q_ASSERT(check);

    check = connect(roster->pushButton_addContact, SIGNAL(clicked()), SLOT(action_addContact()));
    Q_ASSERT(check);


    this->configuration().setPort(m_xmpp_client_port);
    this->configuration().setJid(m_login);
    this->configuration().setPassword(m_password);
    this->configuration().setResource("nodecast");
    this->configuration().setStreamSecurityMode(QXmppConfiguration::StreamSecurityMode::TLSRequired);

    this->connectToServer(this->configuration());
}
Example #23
0
/**
 * @brief TEST_F SdkTestContacts
 *
 * Creates an auxiliar 'MegaApi' object to interact with the main MEGA account.
 *
 * - Invite a contact
 * = Ignore the invitation
 * - Delete the invitation
 *
 * - Invite a contact
 * = Deny the invitation
 *
 * - Invite a contact
 * = Accept the invitation
 *
 * - Remove contact
 *
 * TODO:
 * - Invite a contact not registered in MEGA yet (requires validation of account)
 * - Remind an existing invitation (requires 2 weeks wait)
 */
TEST_F(SdkTest, SdkTestContacts)
{
    ASSERT_NO_FATAL_FAILURE( getMegaApiAux() );    // login + fetchnodes


    // --- Check my email and the email of the contact ---

    EXPECT_STREQ(email.data(), megaApi->getMyEmail());
    EXPECT_STREQ(emailaux.data(), megaApiAux->getMyEmail());


    // --- Send a new contact request ---

    string message = "Hi contact. This is a testing message";

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    ASSERT_NO_FATAL_FAILURE( inviteContact(emailaux, message, MegaContactRequest::INVITE_ACTION_ADD) );

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)


    // --- Check the sent contact request ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(true) );

    ASSERT_STREQ(message.data(), cr->getSourceMessage()) << "Message sent is corrupted";
    ASSERT_STREQ(email.data(), cr->getSourceEmail()) << "Wrong source email";
    ASSERT_STREQ(emailaux.data(), cr->getTargetEmail()) << "Wrong target email";
    ASSERT_EQ(MegaContactRequest::STATUS_UNRESOLVED, cr->getStatus()) << "Wrong contact request status";
    ASSERT_TRUE(cr->isOutgoing()) << "Wrong direction of the contact request";

    delete cr;
    cr = NULL;


    // --- Check received contact request ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false) );

    ASSERT_STREQ(message.data(), craux->getSourceMessage()) << "Message received is corrupted";
    ASSERT_STREQ(email.data(), craux->getSourceEmail()) << "Wrong source email";
    ASSERT_STREQ(NULL, craux->getTargetEmail()) << "Wrong target email";    // NULL according to MegaApi documentation
    ASSERT_EQ(MegaContactRequest::STATUS_UNRESOLVED, craux->getStatus()) << "Wrong contact request status";
    ASSERT_FALSE(craux->isOutgoing()) << "Wrong direction of the contact request";

    delete craux;
    craux = NULL;


    // --- Ignore received contact request ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false) );

    contactRequestUpdatedAux = false;
    ASSERT_NO_FATAL_FAILURE( replyContact(craux, MegaContactRequest::REPLY_ACTION_IGNORE) );
    waitForResponse(&contactRequestUpdatedAux); // only at auxiliar account. Main account is not notified

    delete craux;
    craux = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false, 0) );
    delete craux;
    craux = NULL;


    // --- Cancel the invitation ---

    message = "I don't wanna be your contact anymore";

    contactRequestUpdated = false;
    ASSERT_NO_FATAL_FAILURE( inviteContact(emailaux, message, MegaContactRequest::INVITE_ACTION_DELETE) );
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false, 0) );
    delete craux;
    craux = NULL;

    // The target contact doesn't receive notification, since the invitation was ignored previously


    // --- Remind a contact invitation (cannot until 2 weeks after invitation/last reminder) ---

//    contactRequestReceived = false;
//    megaApi->inviteContact(emailaux.data(), message.data(), MegaContactRequest::INVITE_ACTION_REMIND);
//    waitForResponse(&contactRequestReceived, 30); // at the target side (auxiliar account)

//    ASSERT_TRUE(contactRequestReceived) << "Contact invitation reminder not received after " << timeout  << " seconds";


    // --- Invite a new contact (again) ---

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    ASSERT_NO_FATAL_FAILURE( inviteContact(emailaux, message, MegaContactRequest::INVITE_ACTION_ADD) );

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)


    // --- Deny a contact invitation ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false) );

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    replyContact(craux, MegaContactRequest::REPLY_ACTION_DENY);

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)

    delete craux;
    craux = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(true, 0) );
    delete cr;
    cr = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false, 0) );
    delete craux;
    craux = NULL;


    // --- Invite a new contact (again) ---

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    ASSERT_NO_FATAL_FAILURE( inviteContact(emailaux, message, MegaContactRequest::INVITE_ACTION_ADD) );

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)


    // --- Accept a contact invitation ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false) );

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    ASSERT_NO_FATAL_FAILURE( replyContact(craux, MegaContactRequest::REPLY_ACTION_ACCEPT) );

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)

    delete craux;
    craux = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(true, 0) );
    delete cr;
    cr = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false, 0) );
    delete craux;
    craux = NULL;


    // --- Delete an existing contact ---

    contactRemoved = false;
    ASSERT_NO_FATAL_FAILURE( removeContact(emailaux) );
    waitForResponse(&contactRemoved);

    MegaUser *u = megaApi->getContact(emailaux.data());
    ASSERT_EQ(MegaUser::VISIBILITY_HIDDEN, u->getVisibility()) << "New contact still visible";
    delete u;
}
Example #24
0
void GaduRosterService::handleEventUserlist100GetReply(struct gg_event *e)
{
	if (!m_stateMachine->isPerformingGet())
	{
		kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "got unexpected userlist 100 get reply, ignoring\n");
		return;
	}

	auto accountData = GaduAccountData{account()};
	if (e->event.userlist100_reply.format_type != GG_USERLIST100_FORMAT_TYPE_GG70)
	{
		kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "got userlist 100 reply with unwanted format type (%d)\n", (int)e->event.userlist100_reply.format_type);
		getFinished(false);
		return;
	}

	auto content = e->event.userlist100_reply.reply;
	if (!content)
	{
		kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "got userlist 100 reply without any content\n");
		getFinished(false);
		return;
	}

	kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "userlist 100 reply:\n%s\n", content);

	if (accountData.userlistVersion() != (int)e->event.userlist100_reply.version)
	{
		auto content2 = QByteArray{content};
		auto buddies = m_gaduListHelper->byteArrayToBuddyList(account(), content2);
		getFinished(true);

		auto result = m_rosterReplacer->replaceRoster(account(), buddies, haveToAskForAddingContacts());
		accountData.setUserlistVersion(e->event.userlist100_reply.version);
		accountData.setInitialRosterImport(false);

		for (auto &&contact : result.first)
			contact.rosterEntry()->setSynchronized();

		for (auto &&contact : result.second)
		{
			auto ownerBuddy = contact.ownerBuddy();
			contact.setOwnerBuddy(Buddy::null);
			m_buddyManager->removeBuddyIfEmpty(ownerBuddy, true);
			removeContact(contact);
			contact.rosterEntry()->setSynchronized();
		}

		// cleanup references, so buddy and contact instances can be removed
		// this is really a hack, we need to call aboutToBeRemoved someway for non-manager contacts and buddies too
		// or just only store managed only, i dont know yet
		for (auto &&buddy : buddies)
		{
			for (auto &&contact : buddy.contacts())
				contact.data()->aboutToBeRemoved();
			buddy.data()->aboutToBeRemoved();
		}
	}
	else
	{
		markSynchronizingAsSynchronized();
		getFinished(true);
	}
}
Example #25
0
void SensorSystem::clearContacts(void)
{
	while(numContacts)
		removeContact((int32_t)0);
}
Example #26
0
	TriggerNode::~TriggerNode() {
		while (contacts.count()) {
			contacts[0].removeContact(this);
			removeContact(&contacts[0]);
		}
	}
Example #27
0
void SensorSystem::clearContacts (void) {

	while (numContacts)
		removeContact((long)0);
}
Example #28
0
void SensorSystem::removeContact (MoverPtr contact) {

	long contactIndex = contact->getContactInfo()->getSensor(id);
	if (contactIndex < 255)
		removeContact(contactIndex);
}
Example #29
0
C_ClientWeb::C_ClientWeb(QObject *parent, Client *model_, ClientWeb *view_) :
    QObject(parent), model(model_), view(view_)
{
    connect(view,SIGNAL(removeContactClicked(QString)),this,SLOT(removeContactClicked(QString)));
    connect(view,SIGNAL(removeContact(QString)),this,SLOT(removeContact(QString)));
}
Example #30
0
int main(int argc, char const *argv[]) {
    if (argc == 1) {
        printf("ERROR: the program takes one argument\n");
        return 0;
    }
    argv[1];
    FILE *input = fopen(argv[1], "r");
    Book *book = createBook();
    readBookFromFile(input, book);
    fclose(input);

    sh_fileName = argv[1];
    sh_book = book;
    signal(SIGINT, signal_handler); 

    char command[10];
    char *name = NULL;   //(char *) malloc(sizeof(char)*80);
    char *number = NULL; // (char *) malloc(sizeof(char)*80);
    char *str = NULL;    //(char *) malloc(80);

    bool corName;
    bool corNumber;
    
    while (true) {
        corName = true;
        corNumber = true;
        scanf("%s", command);
        if(!strcmp(command, "debprint")) {
            fullPrint(book);
        } else if(!strcmp(command, "print")) {
            printBook(stdout, book);
        } else if(!strcmp(command, "find")) {
            str = read(stdin);
            printFound(stdout, book, str);
            free(str);
        } else if(!strcmp(command, "create")) {
            name = read(stdin); number = read(stdin);
            corName = correctName(name);
            corNumber = correctNumber(number);
            if (correctName && correctNumber) {
                appendBook(book, name, number);
            }
            free(name); free(number);
        } else if(!strcmp(command, "delete")) {
            int id;
            scanf("%d", &id);
            removeContact(book, id);
        } else if(!strcmp(command, "change")) {
            int id;
            scanf("%d%s", &id, command);
            str = read(stdin);
            if(!strcmp(command, "number")) {
                corName = correctName(str);
                if (corName)
                    changeNumber(book, id, str);
            } else if (!strcmp(command, "name")) {
                corNumber = correctNumber(str);
                if (corNumber)
                    changeName(book, id, str);
            } else {
                printf("ERROR: Expected \"name\" or \"number\" after id in the command change\n");
            }
            free(str);
        } else if(!strcmp(command, "exit")) {
            FILE* output = fopen(argv[1], "w");
            printBook(output, book);
            fclose(output);
            deleteBook(book);
            break;
        } else {
            printf("ERROR: Unknown command %s\n", command);
        }
        if (!corName) {
            printf("ERROR: Invalid name\n");
        }
        if (!corNumber) {
            printf("ERROR: Invalid number\n");
        }
    }

    return 0;
}