Beispiel #1
0
void initYolodex() {
	head = createContact("Robert", "Morris", "(617)253-5982", 32972, 'M', 'y');
	insert(createContact("Chareth", "Cutestory", "(123)456-7890", 4242, 'M', 'n'));
	insert(createContact("Tim", "Berners-Lee", "(638)844-2074", 404, 'M','y'));
	insert(createContact("Pwnies", "McPwn", "(222)223-1337", 31337, 'F','y'));
	insert(createContact("Jenny", "Fakename", "(555)867-5309", 31337, 'F','n'));
}
Beispiel #2
0
void ICQSearchResult::dragStart()
{
    Contact *contact = createContact(CONTACT_TEMP | CONTACT_DRAG);
    if (contact == NULL)
        return;
    tblUser->startDrag(new ContactDragObject(tblUser, contact));
}
Beispiel #3
0
ChatUnit *QuetzalAccount::getUnitForSession(ChatUnit *unit)
{
	if (QuetzalChatUser *user = qobject_cast<QuetzalChatUser*>(unit)) {
		if (user->purple()->buddy)
			return createContact(user->id());
	}
	return unit;
}
Beispiel #4
0
ChatUnit *QuetzalAccount::getUnit(const QString &unitId, bool create)
{
	ChatUnit *unit = m_contacts.value(unitId);
	if (!unit)
		unit = m_units.value(unitId);
	if (!unit && create)
		unit = createContact(unitId);
	return unit;
}
bool StandardContactList::load_contacts(const QDomElement& contacts)
{
    QDomNodeList list = contacts.elementsByTagName("contact");
    for(int i = 0; i < list.size(); i++) {
        QDomElement el = list.at(i).toElement();
        int id = el.attribute("id").toInt();
        ContactPtr c = createContact(id);
        if(!c->deserialize(el))
            return false;
        addContact(c);
    }
    return true;
}
bool Account::addContact(const QString &contactId , MetaContact *parent, AddMode mode )
{
	if ( !protocol()->canAddMyself() && contactId == myself()->contactId() )
	{
		if ( isConnected() && d->lastLoginTime.secsTo(QDateTime::currentDateTime()) > 30 )
		{
			KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error,
			                               i18n("You are not allowed to add yourself to the contact list. The addition of \"%1\" to account \"%2\" will not take place.", contactId, accountId()), i18n("Error Creating Contact")
			                             );
		}
		else
		{
			kWarning(14010) << "You are not allowed to add yourself to the contact list. The addition of" << contactId
			                << "to account" << accountId() << "will not take place.";
		}
		
		return 0L;
	}

	const bool isTemporary= parent->isTemporary();
	Contact *c = d->contacts.value( contactId );
	if ( c && c->metaContact() )
	{
		if ( c->metaContact()->isTemporary() && !isTemporary )
		{
			kDebug( 14010 ) <<
				"Account::addContact: You are trying to add an existing temporary contact. Just add it on the list" << endl;

				//setMetaContact ill take care about the deletion of the old contact
			c->setMetaContact(parent);
			return true;
		}
		else
		{
			// should we here add the contact to the parentContact if any?
			kDebug( 14010 ) << "Account::addContact: Contact already exists";
		}
		return false; //(the contact is not in the correct metacontact, so false)
	}

	const bool success = createContact(contactId, parent);

	if ( success && mode == ChangeKABC )
	{
		kDebug( 14010 ) << " changing KABC";
		KABCPersistence::self()->write( parent );
	}

	return success;
}
Beispiel #7
0
void promptAdd() {
	char first[32];
	char last[32];
	char phone[16];
	char officetmp[8];
	short officenum;
	char gender;
	char hacker;
	char tmp[2];

	contact *ptr;
	memset(phone, 0, 16);
	memset(officetmp, 0, 8);
	ptr = NULL;
	while(ptr == NULL) {
		put("First: ");
		recvUntil(first, 32, '\n');
		put("Last: ");
		recvUntil(last, 32, '\n');
		put("Phone Number: ");
		recvUntil(phone, 14, '\n');
		put("Office Number: ");
		memset(officetmp, 0, 8);
		recvUntil(officetmp, 6, '\n');
		officenum = (unsigned short)atoi(officetmp);
		put("Gender: ");
		recvUntil(tmp, 2, '\n');
		gender = tmp[0];
		hacker = '?';
		while(hacker == '?')
		{
			put("Hacker: ");
			recvUntil(tmp, 2, '\n');
			if(tmp[0] == 'n' || tmp[0] == 'y')
				hacker = tmp[0];
			else
				puts("Please enter y or n for hacker.");
		}
		ptr = createContact(first, last, phone, officenum, gender, hacker);
	}
	if(ptr->cookie != cookie)
	{
		puts("Contact corruption detected.");
		_terminate(-1);
	}
	insert(ptr);
}
bool StandardContactList::load_old()
{
    QString cfgName = ProfileManager::instance()->profilePath() + QDir::separator() + "contacts.conf";
    QFile f(cfgName);
    if (!f.open(QIODevice::ReadOnly)){
        log(L_ERROR, "[2]Can't open %s", qPrintable(cfgName));
        return false;
    }

    ParserState state;
    while(!f.atEnd())
    {
        QString line = QString::fromLocal8Bit(f.readLine());
        line = line.trimmed();
        //log(L_DEBUG, "Line: %s", qPrintable(line));
        if(line.startsWith("[Group="))
        {
            state.nextSection = ParserState::Group;
            load_old_dispatch(state);
            resetState(state);
            state.groupId = line.mid(7, line.length() - 8).toInt();
            if(state.groupId > 0)
                addGroup(createGroup(state.groupId));
        }
        else if(line.startsWith("[Contact="))
        {
            state.nextSection = ParserState::Contact;
            load_old_dispatch(state);
            resetState(state);
            state.contactId = line.mid(9, line.length() - 10).toInt();
            if(state.contactId > 0)
                addContact(createContact(state.contactId));
        }
        else if(line.startsWith("["))
        {
            state.nextSection = ParserState::Client;
            load_old_dispatch(state);
            state.dataname = line.mid(1, line.length() - 2);
        }
        else
        {
            state.data.append(line + "\n");
        }
    }
    return true;
}
bool Account::addContact(const QString &contactId , MetaContact *parent, AddMode mode )
{
	if ( contactId == myself()->contactId() )
	{
	    	KMessageBox::error( Kopete::UI::Global::mainWidget(),
			i18n("You are not allowed to add yourself to the contact list. The addition of \"%1\" to account \"%2\" will not take place.").arg(contactId,accountId()), i18n("Error Creating Contact")
		);
		return 0L;
	}

	bool isTemporary= parent->isTemporary();
	Contact *c = d->contacts[ contactId ];
	if ( c && c->metaContact() )
	{
		if ( c->metaContact()->isTemporary() && !isTemporary )
		{
			kdDebug( 14010 ) <<
				"Account::addContact: You are trying to add an existing temporary contact. Just add it on the list" << endl;

				//setMetaContact ill take care about the deletion of the old contact
			c->setMetaContact(parent);
			return true;
		}
		else
		{
			// should we here add the contact to the parentContact if any?
			kdDebug( 14010 ) << "Account::addContact: Contact already exists" << endl;
		}
		return false; //(the contact is not in the correct metacontact, so false)
	}

	bool success = createContact(contactId, parent);

	if ( success && mode == ChangeKABC )
	{
		kdDebug( 14010 ) << k_funcinfo << " changing KABC" << endl;
		KABCPersistence::self()->write( parent );
	}

	return success;
}
Beispiel #10
0
Contact* insertContact(Contact* prevContact, char* last) {
	Contact* newContact = createContact(last);

	if (prevContact) {
		newContact->prev = prevContact;
		newContact->next = prevContact->next;
		prevContact->next = newContact;
		if (newContact->next) /* Verify there is a next node� */
			newContact->next->prev = newContact;

	} else /* insert node at top of list */
	{
		newContact->prev = NULL; /* for clarity */
		newContact->next = top;
		if (top)
			top->prev = newContact;
		top = newContact;
	}

	return newContact;
}
Beispiel #11
0
void ICQSearchResult::finishClicked()
{
	createContact(false);
}
Beispiel #12
0
void ICQSearchResult::doubleClicked(QListViewItem*)
{
    createContact(false);
}
Kopete::MetaContact* Account::addContact( const QString &contactId, const QString &displayName , Group *group, AddMode mode  )
{

	if ( !protocol()->canAddMyself() && contactId == d->myself->contactId() )
	{
		if ( isConnected() && d->lastLoginTime.secsTo(QDateTime::currentDateTime()) > 30 )
		{
			KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error,
			                               i18n("You are not allowed to add yourself to the contact list. The addition of \"%1\" to account \"%2\" will not take place.", contactId, accountId()), i18n("Error Creating Contact")
			                             );
		}
		else
		{
			kWarning(14010) << "You are not allowed to add yourself to the contact list. The addition of" << contactId
			                << "to account" << accountId() << "will not take place.";
		}
		return 0;
	}

	bool isTemporary = (mode == Temporary);

	Contact *c = d->contacts.value( contactId );

	if(!group)
		group=Group::topLevel();

	if ( c && c->metaContact() )
	{
		if ( c->metaContact()->isTemporary() && !isTemporary )
		{
			kDebug( 14010 ) <<  " You are trying to add an existing temporary contact. Just add it on the list";

			c->metaContact()->setTemporary(false, group );
			ContactList::self()->addMetaContact(c->metaContact());
		}
		else
		{
			// should we here add the contact to the parentContact if any?
			kDebug( 14010 ) << "Contact already exists";
		}
		return c->metaContact();
	}

	MetaContact *parentContact = new MetaContact();
	if(!displayName.isEmpty())
		parentContact->setDisplayName( displayName );

	//Set it as a temporary contact if requested
	if ( isTemporary )
		parentContact->setTemporary( true );
	else
		parentContact->addToGroup( group );

	if ( c )
	{
		c->setMetaContact( parentContact );
		if ( mode == ChangeKABC )
		{
			kDebug( 14010 ) << " changing KABC";
			KABCPersistence::self()->write( parentContact );
		}
	}
	else
	{
		if ( !createContact( contactId, parentContact ) )
		{
			delete parentContact;
			return 0L;
		}
	}

	ContactList::self()->addMetaContact( parentContact );
	return parentContact;
}
Beispiel #14
0
void *ICQSearchResult::processEvent(Event *e)
{
    if ((e->type() > EventUser) && ((m_id1 != SEARCH_DONE) || (m_id2 != SEARCH_DONE))){
        if (e->type() == EventSearch){
            SearchResult *result = (SearchResult*)(e->param());
            if ((result->client == m_client) && (
                        (result->id == m_id1) || (result->id == m_id2))){
                new UserTblItem(tblUser, m_client, &result->data);
                m_nFound++;
                setStatus();
            }
        }
        if (e->type() == EventSearchDone){
            SearchResult *result = (SearchResult*)(e->param());
            if (result->client == m_client){
                if (result->id == m_id1)
                    setRequestId(SEARCH_DONE, m_id2);
                if (result->id == m_id2)
                    setRequestId(m_id1, SEARCH_DONE);
            }
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->menu_id == MenuSearchResult){
            Contact *contact;
            if (cmd->id == CmdIcqSendMessage){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                Message *msg = new Message(MessageGeneric);
                msg->setContact(contact->id());
                Event e(EventOpenMessage, &msg);
                e.process();
                delete msg;
            }
            if (cmd->id == CmdInfo){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                m_client->addFullInfoRequest(atol(tblUser->currentItem()->text(0).latin1()), true);
                Command cmd;
                cmd->id = CmdInfo;
                cmd->menu_id = MenuContact;
                cmd->param   = (void*)contact->id();
                Event e(EventCommandExec, cmd);
                e.process();
            }
            return e->param();
        }
        if (cmd->menu_id == MenuIcqGroups){
            Contact *contact = createContact(0);
            if (!contact) return NULL;
            contact->setGroup(cmd->id - 1);
            Event eContact(EventContactChanged, contact);
            eContact.process();
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->menu_id == MenuIcqGroups) &&
                (cmd->id == CmdGroups)){
            unsigned n = 1;
            ContactList::GroupIterator it;
            while (++it)
                n++;
            CommandDef *cmds = new CommandDef[n];
            memset(cmds, 0, sizeof(CommandDef) * n);
            n = 0;
            it.reset();
            Group *grp;
            while ((grp = ++it) != NULL){
                cmds[n].id		 = grp->id() + 1;
                cmds[n].text	 = "_";
                QString name = grp->getName();
                if (grp->id() == 0)
                    name = i18n("Not in list");
                cmds[n].text_wrk = strdup(name.utf8());
                n++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
    }
    return NULL;
}
Beispiel #15
0
void *SearchDialog::processEvent(Event *e)
{
    switch (e->type()){
    case EventClientsChanged:
    case EventClientChanged:
        fillClients();
        break;
    case EventCommandExec:{
            if (m_result != m_currentResult)
                return NULL;
            CommandDef *cmd = (CommandDef*)(e->param());
            if (cmd->menu_id == MenuSearchGroups){
                Group *grp = getContacts()->group(cmd->id - CmdContactGroup);
                if (grp){
                    Contact *contact = NULL;
                    if ((QWidget*)(cmd->param) == m_search->btnSearch){
                        if (m_current){
                            connect(this, SIGNAL(createContact(unsigned,Contact*&)), m_current, SLOT(createContact(unsigned,Contact*&)));
                            emit createContact(CONTACT_TEMP, contact);
                            disconnect(this, SIGNAL(createContact(unsigned,Contact*&)), m_current, SLOT(createContact(unsigned,Contact*&)));
                        }
                    }else{
                        contact = createContact(CONTACT_TEMP);
                    }
                    if (contact){
                        if ((contact->getFlags() & CONTACT_TEMP) == 0){
                            QString err = i18n("%1 already in contact list") .arg(contact->getName());
                            if ((QWidget*)(cmd->param) == m_search->btnAdd){
                                BalloonMsg::message(err, m_search->btnAdd);
                            }else if ((QWidget*)(cmd->param) == m_search->btnSearch){
                                BalloonMsg::message(err, m_search->btnSearch);
                            }else{
                                BalloonMsg::message(err, m_result);
                            }
                            return e->param();
                        }
                        contact->setFlags(contact->getFlags() & ~CONTACT_TEMP);
                        contact->setGroup(grp->id());
                        Event e(EventContactChanged, contact);
                        e.process();
                    }
                }
                return e->param();
            }
            if (cmd->id == CmdSearchInfo){
                Contact *contact = createContact(CONTACT_TEMP);
                if (contact == NULL)
                    return e->param();
                Command cmd;
                cmd->id		 = CmdInfo;
                cmd->menu_id = MenuContact;
                cmd->param   = (void*)(contact->id());
                CorePlugin::m_plugin->showInfo(cmd);
                return e->param();
            }
            if (cmd->id == CmdSearchMsg){
                Contact *contact = createContact(CONTACT_TEMP);
                if (contact == NULL)
                    return e->param();
                Message *m = new Message(MessageGeneric);
                m->setContact(contact->id());
                Event e(EventOpenMessage, &m);
                e.process();
                delete m;
            }
            break;
        }
Kopete::MetaContact* Account::addContact( const QString &contactId, const QString &displayName , Group *group, AddMode mode  )
{

	if ( contactId == d->myself->contactId() )
	{
		KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error,
			i18n("You are not allowed to add yourself to the contact list. The addition of \"%1\" to account \"%2\" will not take place.").arg(contactId,accountId()), i18n("Error Creating Contact")
		);
        return nullptr;
	}
 
	bool isTemporary = mode == Temporary;

	Contact *c = d->contacts[ contactId ];

	if(!group)
		group=Group::topLevel();

	if ( c && c->metaContact() )
	{
		if ( c->metaContact()->isTemporary() && !isTemporary )
		{
			kdDebug( 14010 ) << k_funcinfo <<  " You are trying to add an existing temporary contact. Just add it on the list" << endl;

			c->metaContact()->setTemporary(false, group );
			ContactList::self()->addMetaContact(c->metaContact());
		}
		else
		{
			// should we here add the contact to the parentContact if any?
			kdDebug( 14010 ) << k_funcinfo << "Contact already exists" << endl;
		}
		return c->metaContact();
	}

	MetaContact *parentContact = new MetaContact();
	if(!displayName.isEmpty())
		parentContact->setDisplayName( displayName );

	//Set it as a temporary contact if requested
	if ( isTemporary )
		parentContact->setTemporary( true );
	else
		parentContact->addToGroup( group );

	if ( c )
	{
		c->setMetaContact( parentContact );
		if ( mode == ChangeKABC )
		{
			kdDebug( 14010 ) << k_funcinfo << " changing KABC" << endl;
			KABCPersistence::self()->write( parentContact );
		}
	}
	else
	{
		if ( !createContact( contactId, parentContact ) )
		{
			delete parentContact;
			return 0L;
		}
	}

	ContactList::self()->addMetaContact( parentContact );
	return parentContact;
}
Beispiel #17
0
void AddResult::finish()
{
    if (tblUser->isVisible() && tblUser->currentItem())
        createContact(0);
}
Beispiel #18
0
void *AddResult::processEvent(Event *e)
{
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->menu_id == MenuSearchResult){
            Contact *contact;
            if (cmd->id == CmdJabberMessage){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                Message *msg = new Message(MessageGeneric);
                msg->setContact(contact->id());
                Event e(EventOpenMessage, &msg);
                e.process();
                delete msg;
            }
            if (cmd->id == CmdInfo){
                JabberUserData *data;
                contact = createContact(CONTACT_TEMP, &data);
                if (!contact) return NULL;
                m_client->updateInfo(contact, data);
                Command cmd;
                cmd->id = CmdInfo;
                cmd->menu_id = MenuContact;
                cmd->param   = (void*)contact->id();
                Event e(EventCommandExec, cmd);
                e.process();
            }
            return e->param();
        }
        if (cmd->menu_id == MenuJabberGroups){
            Contact *contact = createContact(0);
            if (!contact) return NULL;
            contact->setGroup(cmd->id - 1);
            Event eContact(EventContactChanged, contact);
            eContact.process();
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->menu_id == MenuJabberGroups) &&
                (cmd->id == CmdGroups)){
            unsigned n = 1;
            ContactList::GroupIterator it;
            while (++it)
                n++;
            CommandDef *cmds = new CommandDef[n];
            memset(cmds, 0, sizeof(CommandDef) * n);
            n = 0;
            it.reset();
            Group *grp;
            while ((grp = ++it) != NULL){
                cmds[n].id		 = grp->id() + 1;
                cmds[n].text	 = "_";
                QString name = grp->getName();
                if (grp->id() == 0)
                    name = i18n("Not in list");
                cmds[n].text_wrk = strdup(name.utf8());
                n++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
    }
    if (e->type() == EventSearch){
        JabberSearchData *data = (JabberSearchData*)(e->param());
        if (m_searchId == data->ID.ptr){
            if (m_bXSearch){
                if (data->JID.ptr){
                    m_nFound++;
                    lblStatus->setText(i18n("Search") + foundStatus());
                    QListViewItem *item = new QListViewItem(tblUser);
                    item->setText(0, QString::fromUtf8(data->JID.ptr));
                    for (unsigned col = 0; col < data->nFields.value; col++)
                        item->setText(col + 1, QString::fromUtf8(get_str(data->Fields, col)));
                }else{
                    for (unsigned col = 0; col < data->nFields.value; col++)
                        tblUser->addColumn(QString::fromUtf8(get_str(data->Fields, col)));
                    tblUser->adjustColumn();
                }
            }else{
                m_nFound++;
                lblStatus->setText(i18n("Search") + foundStatus());
                QListViewItem *item = new QListViewItem(tblUser);
                if (data->JID.ptr)
                    item->setText(0, QString::fromUtf8(data->JID.ptr));
                if (data->Nick.ptr)
                    item->setText(1, QString::fromUtf8(data->Nick.ptr));
                if (data->First.ptr)
                    item->setText(2, QString::fromUtf8(data->First.ptr));
                if (data->Last.ptr)
                    item->setText(3, QString::fromUtf8(data->Last.ptr));
                if (data->EMail.ptr)
                    item->setText(4, QString::fromUtf8(data->EMail.ptr));
            }
        }
    }
    if ((e->type() == EventSearchDone) && (m_searchId == (const char*)(e->param()))){
        lblStatus->setText(i18n("Search done") + foundStatus());
        m_searchId = "";
        tblUser->adjustColumn();
        currentChanged(NULL);
    }
    return NULL;
}