Esempio n. 1
0
void ForwardConfig::apply(PropertyHubPtr data)
{
    //ForwardUserData *data = (ForwardUserData*)_data;
    data->setValue("Send1st",   chkFirst->isChecked()       );
    data->setValue("Translit",  chkTranslit->isChecked()    );
    data->setValue("Phone",     cmbPhone->lineEdit()->text());
}
bool StandardContactList::deserializeLines(const UserDataPtr& ud, const QString& dataname, const QString& data)
{
    PropertyHubPtr hub = ud->getUserData(dataname);
    if(!hub)
        hub = ud->createUserData(dataname);
    QStringList list = data.split('\n');
    foreach(const QString& s, list)
    {
        QStringList keyval = s.split('=');
        if(keyval.size() != 2)
            continue;
        if(keyval.at(1).startsWith('\"') && keyval.at(1).endsWith('\"') )
            hub->setValue(keyval.at(0), keyval.at(1).mid(1, keyval.at(1).size() - 2));
        else
            hub->setValue(keyval.at(0), keyval.at(1));
    }
Esempio n. 3
0
void ActionConfig::apply(PropertyHubPtr data)
{
    //ActionUserData *data = (ActionUserData*)_data;
    if (m_menu)
        m_menu->apply(data);

    for (int row = 0; row < lstEvent->rowCount(); ++row)
    {
        unsigned id = lstEvent->item(row, 0)->data(Qt::UserRole).toUInt();
        const QString text = lstEvent->item(row, 1)->data(Qt::EditRole).toString();

        if (id == CONTACT_ONLINE)
            data->setValue("OnLine", text);
        else if (id == CONTACT_STATUS)
            data->setValue("Status", text);
        else
            data->setStringMapValue("Message",id, text);
    }
}
Esempio n. 4
0
 bool Client::serialize(QDomElement& element)
 {
     PropertyHubPtr hub = PropertyHub::create();
     hub->setValue("Password", cryptPassword(password()));
     return hub->serialize(element);
 }
Esempio n. 5
0
bool FilterPlugin::processEvent(Event *e)
{
    switch (e->type()) {
    case eEventContact: {
        EventContact *ec = static_cast<EventContact*>(e);
        if(ec->action() != EventContact::eChanged)
            break;
        Contact *contact = ec->contact();
        if (contact->getGroup()){
            Command cmd;
            cmd->id		= CmdIgnore;
            cmd->flags	= BTN_HIDE;
            cmd->param  = (void*)(contact->id());
            EventCommandShow(cmd).process();
        }
        break;
    }
    case eEventPluginLoadConfig:
    {
        setPropertyHub( ProfileManager::instance()->getPropertyHub("filter") );
        break;
    }
    case eEventMessageReceived: {
        EventMessage *em = static_cast<EventMessage*>(e);
        Message *msg = em->msg();
        if (!msg || (msg->type() == MessageStatus))
            return false;
        Contact *contact = getContacts()->contact(msg->contact());
        PropertyHubPtr data = contact->getUserData("filter");
        // check if we accept only from users on the list
        if (((contact == NULL) || contact->getFlags() & CONTACT_TEMPORARY) &&
                        ((value("FromList").toBool() &&
			  msg->type() != MessageAuthRequest &&
			  msg->type() != MessageAuthGranted &&
			  msg->type() != MessageAuthRefused) ||
                (value("AuthFromList").toBool() && msg->type() <= MessageContacts))) {
            delete msg;
            delete contact;
            return msg;
        }
        if (!contact)
            return false;
        // check if the user is a ignored user
        if (contact->getIgnore()){
            delete msg;
            return true;
        }

        // get filter-data
		if (data && !data->value("SpamList").toString().isEmpty() && (!contact || (contact->getFlags() & CONTACT_TEMPORARY) )) {
            if (checkSpam(msg->getPlainText(), data->value("SpamList").toString())){
                delete msg;
                return true;
            }
		}
        break;
    }
    case eEventCheckCommandState: {
        EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
        CommandDef *cmd = ecs->cmd();
        if (cmd->id == CmdIgnore){
            cmd->flags &= ~BTN_HIDE;
            Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
            if (contact && contact->getGroup())
                cmd->flags |= BTN_HIDE;
            return true;
        }
        if (cmd->id == CmdIgnoreText){
            cmd->flags &= ~COMMAND_CHECKED;
            if (cmd->menu_id == MenuMsgView){
                MsgViewBase *edit = (MsgViewBase*)(cmd->param);
                if (edit->textCursor().hasSelection())
                    return true;
            } else
            /*if (cmd->menu_id == MenuTextEdit){
                TextEdit *edit = ((MsgEdit*)(cmd->param))->m_edit;
                if (edit->textCursor().hasSelection())
                    return true;
            }*/							//Fixme Block (crashing on rightclick in msgedit from container)
            return false;
        }
        if (cmd->menu_id == MenuContactGroup){
            if (cmd->id == CmdIgnoreList){
                Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
                if (contact == NULL)
                    return false;
                cmd->flags &= COMMAND_CHECKED;
                if (contact->getIgnore())
                    cmd->flags |= COMMAND_CHECKED;
                return true;
            }
        }
        break;
    }
    case eEventCommandExec: {
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *cmd = ece->cmd();
        if (cmd->id == CmdIgnore){
            Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
            if (contact){
                QString text = i18n("Add %1 to ignore list?") .arg(contact->getName());
                Command cmd;
                cmd->id		= CmdIgnore;
                cmd->param	= (void*)(contact->id());
                EventCommandWidget eWidget(cmd);
                eWidget.process();
                QWidget *w = eWidget.widget();
                BalloonMsg::ask((void*)(contact->id()), text, w, SLOT(addToIgnore(void*)), NULL, NULL, this);
            }
            return true;
        }
        if (cmd->id == CmdIgnoreText){
            QString text;
            unsigned id = 0;
            if (cmd->menu_id == MenuMsgView){
                MsgViewBase *view = (MsgViewBase*)(cmd->param);
                if (view->textCursor().hasSelection()){
                    text = view->textCursor().selectedText();
                    text = unquoteText(text);
                    id = view->m_id;
                }
            }else if (cmd->menu_id == MenuTextEdit){
                MsgEdit *medit = (MsgEdit*)(cmd->param);
                TextEdit *edit = medit->m_edit;
                if (edit->textCursor().hasSelection()){
                    text = edit->textCursor().selectedText();
                    text = unquoteText(text);
                    id = medit->m_userWnd->id();
                }
            }
            
            Contact *contact = getContacts()->contact(id);
            PropertyHubPtr data = contact->getUserData("filter");

            QString s = data->value("SpamList").toString();
            while (!text.isEmpty()){
                QString line = getToken(text, '\n');
                line = line.remove('\r');
                if (line.isEmpty())
                    continue;
                bool bSpace = false;
                for (int i = 0; i < (int)(line.length()); i++)
                    if (line[i] == ' '){
                        bSpace = true;
                        break;
                    }
                if (bSpace)
                    line = '\"' + line + '\"';
                if (!s.isEmpty())
                    s += ' ';
                s += line;
            }
            data->setValue("SpamList", s);
            return false;
        }
        if (cmd->menu_id == MenuContactGroup)
        {
            if (cmd->id == CmdIgnoreList)
            {
                Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
                if (!contact)
                    return false;
                contact->setIgnore((cmd->flags & COMMAND_CHECKED) == 0);
                EventContact(contact, EventContact::eChanged).process();
                return true;
            }
        }
        break;
    }
    default:
        break;
    }