Exemplo 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());
}
Exemplo n.º 2
0
 bool Client::deserialize(QDomElement& element)
 {
     PropertyHubPtr hub = PropertyHub::create();
     if(!hub->deserialize(element))
         return false;
     setPassword(uncryptPassword(hub->value("Password").toString()));
     return true;
 }
Exemplo n.º 3
0
bool ShortcutsPlugin::processEvent(Event *e)
{
#ifdef WIN32
    if (e->type() == eEventInit){
        init();
        return false;
    } else
#endif
    if (e->type() == eEventCommandCreate){
        EventCommandCreate *ecc = static_cast<EventCommandCreate*>(e);
        CommandDef *cmd = ecc->cmd();
        if ((cmd->menu_id == MenuMain) ||
                (cmd->menu_id == MenuContact) ||
                (cmd->menu_id == MenuStatus) ||
                (cmd->menu_id == MenuGroup)){
            applyKey(cmd);
        }
    } else
    if (e->type() == eEventCommandRemove){
        EventCommandRemove *ecr = static_cast<EventCommandRemove*>(e);
        unsigned long id = ecr->id();
        MAP_STR::iterator it_key = oldKeys.find(id);
        if (it_key != oldKeys.end())
            oldKeys.erase(it_key);
        MAP_BOOL::iterator it_global = oldGlobals.find(id);
        if (it_global != oldGlobals.end())
            oldGlobals.erase(it_global);
        if (globalKeys){
            list<GlobalKey*>::iterator it;
            for (it = globalKeys->begin(); it != globalKeys->end();){
                if ((*it)->id() != id){
                    ++it;
                    continue;
                }
                delete *it;
                globalKeys->erase(it);
                it = globalKeys->begin();
            }
        }
        for (MAP_CMDS::iterator it = mouseCmds.begin(); it != mouseCmds.end();){
            if (it->second.id != id){
                ++it;
                continue;
            }
            mouseCmds.erase(it);
            it = mouseCmds.begin();
        }
        if (mouseCmds.size() == 0)
            qApp->removeEventFilter(this);
    }
	if(e->type() == eEventPluginLoadConfig)
	{
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("shortcut");
        if(!hub.isNull())
            setPropertyHub(hub);
	}
    return false;
}
Exemplo n.º 4
0
bool BackgroundPlugin::processEvent(Event *e)
{
    if (e->type() == eEventPaintView){
        EventPaintView *ev = static_cast<EventPaintView*>(e);
        EventPaintView::PaintView *pv = ev->paintView();;
        if (!bgImage.isNull()){
            unsigned w = bgImage.width();
            unsigned h = bgImage.height();
            int x = pv->pos.x();
            int y = pv->pos.y();
            bool bTiled = false;
            unsigned pos = value("Position").toUInt();
            switch(pos){
            case ContactLeft:
                h = pv->height;
                bTiled = true;
                break;
            case ContactScale:
                h = pv->height;
                w = pv->win->width();
                bTiled = true;
                break;
            case WindowTop:
                break;
            case WindowBottom:
                y += (bgImage.height() - pv->win->height());
                break;
            case WindowCenter:
                y += (bgImage.height() - pv->win->height()) / 2;
                break;
            case WindowScale:
                w = pv->win->width();
                h = pv->win->height();
                break;
            }
            const QPixmap &bg = makeBackground(w, h);
            if (bTiled){
                for (int py = 0; py < pv->size.height(); py += bg.height()){
                    pv->p->drawPixmap(QPoint(0, py), bgScale, QRect(x, 0, w, h));
                }
            }else{
                pv->p->drawPixmap(QPoint(0, 0), bgScale, QRect(x, y, pv->size.width(), pv->size.height()));
                pv->isStatic = true;
            }
        }
        pv->margin = pv->isGroup ? value("MarginGroup").toUInt() : value("MarginContact").toUInt();
    }
    else if(e->type() == eEventPluginLoadConfig)
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("_core");
        if(!hub.isNull())
            setPropertyHub(hub);
        redraw();
    }
    return false;
}
Exemplo n.º 5
0
bool ReplacePlugin::processEvent(SIM::Event *e)
{
    if(e->type() == eEventPluginLoadConfig)
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("replace");
        if(!hub.isNull())
            setPropertyHub(hub);
    }
    return false;
}
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));
    }
Exemplo n.º 7
0
bool IconsPlugin::processEvent(Event *e)
{
    switch (e->type())
    {
    case eEventPluginLoadConfig:
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("icon");
        if(!hub.isNull())
            setPropertyHub(hub);
        setIcons(false);
        break;
    }
    default:
        break;
    }
    return false;
}
Exemplo n.º 8
0
bool NetmonitorPlugin::processEvent(Event *e)
{
    if (e->type() == eEventCommandExec){
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *cmd = ece->cmd();
        if (cmd->id == CmdNetMonitor){
            showMonitor();
            return true;
        }
    }
    else if(e->type() == eEventPluginLoadConfig)
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("netmonitor");
        if(!hub.isNull())
            setPropertyHub(hub);
    }
    return false;
}
Exemplo n.º 9
0
ForwardConfig::ForwardConfig(QWidget *parent, PropertyHubPtr data, ForwardPlugin *plugin) : QWidget(parent)
{
	setupUi(this);
    m_plugin = plugin;
    //PropertyHubPtr data = (ForwardUserData*)_data;
    chkFirst->   setChecked(data->value("Send1st")  .toBool());
    chkTranslit->setChecked(data->value("Translit") .toBool());
    cmbPhone->setEditable(true);
    QString phones = getContacts()->owner()->getPhones();
    while (!phones.isEmpty())
    {
        QString item = getToken(phones, ';', false);
        QString number = getToken(item, ',');
        getToken(item, ',');
        if (item.toULong() == CELLULAR)
            cmbPhone->insertItem(INT_MAX,number);
    }
    cmbPhone->lineEdit()->setText(data->value("Phone").toString());
}
Exemplo n.º 10
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);
    }
}
Exemplo n.º 11
0
 bool Client::serialize(QDomElement& element)
 {
     PropertyHubPtr hub = PropertyHub::create();
     hub->setValue("Password", cryptPassword(password()));
     return hub->serialize(element);
 }
Exemplo n.º 12
0
bool SoundPlugin::processEvent(SIM::Event *e)
{
    switch (e->type())
    {
    case eEventLoginStart:
        {
            playSound(value("StartUp").toString());
            break;
        }
    case eEventPluginLoadConfig:
        {
            PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("sound");
            if(!hub.isNull())
                setPropertyHub(hub);
            if(!value("StartUp").isValid())
                setValue("StartUp", "sounds/startup.ogg");
            if(!value("MessageSent").isValid())
                setValue("MessageSent", "sounds/msgsent.ogg");
            if(!value("FileDone").isValid())
                setValue("FileDone", "sounds/filedone.ogg");
            break;
        }
    case eEventContact:
        {
            EventContact *ec = static_cast<EventContact*>(e);
            if(ec->action() != EventContact::eOnline)
                break;
            Contact *contact = ec->contact();
            bool disable = contact->getUserData()->root()->value("sound/Disable").toBool();
            QString alert = contact->getUserData()->root()->value("sound/Alert").toString();
            if(alert.isEmpty())
                alert = getContacts()->userdata()->value("sound/Alert").toString();
            if (!alert.isEmpty() && !disable)
                EventPlaySound(alert).process();
            break;
        }
    case eEventMessageSent:
        {
            EventMessage *em = static_cast<EventMessage*>(e);
            Message *msg = em->msg();
            QString err = msg->getError();
            if (!err.isEmpty())
                return false;
            QString sound;
            if (msg->type() == MessageFile)
                sound = value("FileDone").toString();
            else if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0)
            {
                if ((msg->getFlags() & MESSAGE_MULTIPLY) && ((msg->getFlags() & MESSAGE_LAST) == 0))
                    return false;
                sound = value("MessageSent").toString();
            }
            if (!sound.isEmpty())
                EventPlaySound(sound).process();
            break;
        }
    case eEventMessageReceived:
        {
            EventMessage *em = static_cast<EventMessage*>(e);
            Message *msg = em->msg();
            if(msg->type() == MessageStatus)
                return false;
            Contact *contact = getContacts()->contact(msg->contact());
            bool nosound, disable;
            if(contact)
            {
                nosound = contact->getUserData()->root()->value("sound/NoSoundIfActive").toBool();
                disable = contact->getUserData()->root()->value("sound/Disable").toBool();
            }
            else
            {
                nosound = getContacts()->userdata()->value("sound/NoSoundIfActive").toBool();
                disable = getContacts()->userdata()->value("sound/Disable").toBool();
            }
            if(!disable && nosound)
            {
                EventActiveContact e;
                e.process();
                if (e.contactID() == contact->id())
                    disable = true;
            }
            if(!disable)
            {
                QString sound = messageSound(msg->baseType(), contact->id());
                playSound(sound);
            }
            break;
        }
    case eEventPlaySound:
        {
            EventPlaySound *s = static_cast<EventPlaySound*>(e);
            playSound(s->sound());
            return true;
        }
    default:
        break;
    }
    return false;
}
Exemplo n.º 13
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;
    }
Exemplo n.º 14
0
bool ActionPlugin::processEvent(Event *e)
{
    switch (e->type() ) {
    case eEventCheckCommandState: {
        EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
        CommandDef *cmd = ecs->cmd();
        if ((cmd->id == CmdAction) && (cmd->menu_id == MenuContact)){
            Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
            if (contact == NULL)
                return false;
            PropertyHubPtr data = contact->getUserData("action");
            if (!data || data->value("NMenu").toInt() == 0)
                return false;
            CommandDef *cmds = new CommandDef[data->value("NMenu").toInt() + 1];
            unsigned n = 0;
            for (int i = 0; i < data->value("NMenu").toInt(); i++){
                QString str = data->stringMapValue("Menu", i +1);
                QString item = getToken(str, ';');
                int pos = item.indexOf("&IP;");
                if (pos >= 0)
                {
                    EventGetContactIP e(contact);
                    if (!e.process())
                        continue;
                }
                pos = item.indexOf("&Mail;");
                if (pos >= 0)
                {
                    if (contact->getEMails().isEmpty())
                        continue;
                }
                pos = item.indexOf("&Phone;");
                if (pos >= 0)
                {
                    if (contact->getPhones().isEmpty())
                        continue;
                }
                cmds[n].id = CmdAction + i;
                cmds[n].text = "_";
                cmds[n].text_wrk = item;
                n++;
            }
            if (n == 0)
            {
                delete[] cmds;
                return false;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return true;
        }
        break;
    }
    case eEventCommandExec: {
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *cmd = ece->cmd();
        if ((cmd->menu_id == MenuContact) && (cmd->id >= CmdAction)){
            unsigned n = cmd->id - CmdAction;
            Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
            PropertyHubPtr data = contact->getUserData("action");
            if (!contact || !data  || n >=  data->value("NMenu").toLongLong())
                return false;

            QString str = data->stringMapValue("Menu", n +1);
            getToken(str, ';');
            EventTemplate::TemplateExpand t;
            t.tmpl     = str;
            t.contact  = contact;
            t.receiver = this;
            t.param    = NULL;
            EventTemplateExpand(&t).process();
            return true;
        }
        break;
    }
    case eEventContact: {
        EventContact *ec = static_cast<EventContact*>(e);
        if(ec->action() != EventContact::eOnline)
            break;
        Contact *contact = ec->contact();
        if (contact == NULL)
            return false;
        PropertyHubPtr data = contact->getUserData("action");
        if (!data || data->value("OnLine").toString().isEmpty())
            return false;
        EventTemplate::TemplateExpand t;
        t.tmpl     = data->value("OnLine").toString();
        t.contact  = contact;
        t.receiver = this;
        t.param    = NULL;
        EventTemplateExpand(&t).process();
        return true;
    }
    case eEventMessageReceived: {
        EventMessage *em = static_cast<EventMessage*>(e);
        Message *msg = em->msg();
        Contact *contact = getContacts()->contact(msg->contact());
        if (contact == NULL)
            return false;
        PropertyHubPtr data = contact->getUserData("action");
        if (!data)
            return false;
        if (msg->type() == MessageStatus){
            if (data->value("Status").toString().isEmpty())
                return false;
            EventTemplate::TemplateExpand t;
            t.tmpl     = data->value("Status").toString();
            t.contact  = contact;
            t.receiver = this;
            t.param    = NULL;
            EventTemplateExpand(&t).process();
            return false;
        }
        QString cmd = data->stringMapValue("Message",msg->baseType());
        if (cmd.isEmpty())
            return false;
        EventTemplate::TemplateExpand t;
        t.tmpl	   = cmd;
        t.contact  = contact;
        t.receiver = this;
        t.param	   = msg;
        EventTemplateExpand(&t).process();
        return true;
    }
    case eEventTemplateExpanded: {
        EventTemplate *et = static_cast<EventTemplate*>(e);
        EventTemplate::TemplateExpand *t = et->templateExpand();
        Message *msg = (Message*)(t->param);
        QProcess *proc;
        if (msg){
            QString text = t->tmpl + unquoteText(msg->presentation());
            proc = new MsgProcess(msg, this);
            connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)),
                    this, SLOT(msg_ready(int, QProcess::ExitStatus)));
            proc->start(text);
        }else{
            proc = new QProcess(this);
            connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)),
                    this, SLOT(ready(int, QProcess::ExitStatus)));
            proc->start(t->tmpl);
        }
        break;
    }
    default:
        break;
    }
Exemplo n.º 15
0
bool DockPlugin::processEvent(Event *e)
{
    switch (e->type())
    {
    case eEventInit:
        init();
        break;
    case eEventQuit:
        if (m_dock){
            delete m_dock;
            m_dock = NULL;
        }
        break;
    case eEventRaiseWindow: 
    {
        EventRaiseWindow *w = static_cast<EventRaiseWindow*>(e);
        if (w->widget() == getMainWindow()){
            if (!m_dock)
                init();
            if (!value("ShowMain").toBool())
                return true;
        }
        break;
    }
    case eEventCommandCreate: 
    {
        EventCommandCreate *ecc = static_cast<EventCommandCreate*>(e);
        CommandDef *def = ecc->cmd();
        if (def->menu_id == MenuMain)
        {
            CommandDef d = *def;
            if (def->flags & COMMAND_IMPORTANT)
            {
                if (d.menu_grp == 0)
                    d.menu_grp = 0x1001;
            }
            else
                d.menu_grp = 0;
            d.menu_id = DockMenu;
            d.bar_id  = 0;
            EventCommandCreate(&d).process();
        }
        break;
    }
    case eEventCheckCommandState: 
    {
        EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
        CommandDef *def = ecs->cmd();
        if (def->id == CmdToggle)
        {
            def->flags &= ~COMMAND_CHECKED;
            def->text = isMainShow() ?
                        I18N_NOOP("Hide main window") :
                        I18N_NOOP("Show main window");
            return true;
        }
        break;
    }
    case eEventCommandExec: 
    {
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *def = ece->cmd();
        if (def->id == CmdToggle)
        {
            QWidget *main = getMainWindow();
            if(!main)
                return false;
            if (isMainShow())
            {
                setValue("ShowMain", false);
                main->hide();
            }
            else
            {
                m_inactiveTime = QDateTime();
                setValue("ShowMain", true);
                raiseWindow(main, value("Desktop").toUInt());
            }
            return true;
        }
        if (def->id == CmdCustomize){
            EventMenu(DockMenu, EventMenu::eCustomize).process();
            return true;
        }
        if (def->id == CmdQuit)
            m_bQuit = true;
        break;
    }
    case eEventPluginLoadConfig:
    {
        PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("dock");
        if(!hub.isNull())
            setPropertyHub(hub);
        break;
    }
    default:
        break;
    }
    return false;
}