Exemple #1
0
MessageConfig::MessageConfig(QWidget *parent, SIM::PropertyHubPtr _data)
  : QWidget(parent)
{
    setupUi(this);
    m_file = NULL;
    for (QObject *p = parent; p != NULL; p = p->parent()){
        QTabWidget *tab = qobject_cast<QTabWidget*>(p);
        if(!tab)
            continue;
        m_file = new FileConfig(tab, _data);
        tab->addTab(m_file, i18n("File"));
        tab->adjustSize();
        break;
    }

	SIM::PropertyHubPtr data = _data;
    chkOnline->setChecked(data->value("OpenOnOnline").toBool());
    chkStatus->setChecked(data->value("LogStatus").toBool());
    switch (data->value("OpenNewMessage").toUInt()){
    case NEW_MSG_NOOPEN:
        btnNoOpen->setChecked(true);
        break;
    case NEW_MSG_MINIMIZE:
        btnMinimize->setChecked(true);
        break;
    case NEW_MSG_RAISE:
        btnRaise->setChecked(true);
        break;
    }
}
Exemple #2
0
QString SoundPlugin::messageSound(unsigned type, unsigned long contact_id)
{
    SIM::PropertyHubPtr data;
    Contact *c = getContacts()->contact(contact_id);
    if(!contact_id)
        data = getContacts()->userdata();
    else if(c)
    {
        data = c->getUserData()->root();
        if(!data->value("sound/override").toBool())
        {
            Group* g = getContacts()->group(c->getGroup(), false);
            if(g->userdata()->value("sound/override").toBool())
                data = g->userdata();
            else
                data = getContacts()->userdata();
        }
    }
    QString sound;
    if(data)
        sound = data->value("sound/Receive" + QString::number(type)).toString();
    if(sound == "(nosound)")
        return QString();
    return sound;
}
ActionConfig::ActionConfig(QWidget *parent, SIM::PropertyHubPtr data, ActionPlugin *plugin)
  : QWidget(parent)
  , m_menu(NULL)
  , m_data(data)
  , m_plugin(plugin)
{
    setupUi(this);
    setButtonsPict(this);

    connect(btnHelp, SIGNAL(clicked()), this, SLOT(help()));

    int row = 0;
    addRow(lstEvent, row, Icon("SIM"), i18n("Contact online"), CONTACT_ONLINE, data->value("OnLine").toString() );

    row++;
    addRow(lstEvent, row, Icon("SIM"), i18n("Status changed"), CONTACT_STATUS, data->value("Status").toString() );

    CommandDef *cmd;
    CorePlugin *core = GET_CorePlugin();
    CommandsMapIterator it(core->messageTypes);
    while ((cmd = ++it) != NULL){
        MessageDef *def = (MessageDef*)(cmd->param);
        if ((def == NULL) || (cmd->icon.isEmpty()) ||
                (def->flags & (MESSAGE_HIDDEN | MESSAGE_SENDONLY | MESSAGE_CHILD)))
            continue;
        if ((def->singular == NULL) || (def->plural == NULL) ||
                (*def->singular == 0) || (*def->plural == 0))
            continue;
        QString type = i18n(def->singular, def->plural, 1);
        int pos = type.indexOf("1 ");
        if (pos == 0){
            type = type.mid(2);
        }else if (pos > 0){
            type = type.left(pos);
        }
        type = type.left(1).toUpper() + type.mid(1);

        row++;
        addRow(lstEvent, row, Icon(cmd->icon), type, cmd->id, data->stringMapValue("Message", cmd->id));
    }
    EventTmplHelpList e;
    e.process();
    LineEditDelegate *dg = new LineEditDelegate(1, lstEvent);
    dg->setHelpList(e.helpList());
    lstEvent->setItemDelegate(dg);
    lstEvent->resizeColumnToContents(0);
    lstEvent->sortByColumn(0, Qt::AscendingOrder);

    for (QObject *p = parent; p != NULL; p = p->parent()){
        QTabWidget *tab = qobject_cast<QTabWidget*>(p);
        if (!tab)
            continue;
        m_menu = new MenuConfig(tab, data);
        tab->addTab(m_menu, i18n("Menu"));
        tab->adjustSize();
        break;
    }
}
Exemple #4
0
void History::add(Message *msg, const QString &type)
{
    QByteArray line = "[";
    line += type.toUtf8();
    line += "]\n";
    line += msg->save();
    line += '\n';

    if (msg->getFlags() & MESSAGE_TEMP)
    {
        if (s_tempMsg == NULL)
            s_tempMsg = new MAP_MSG;
        msg_save ms;
        ms.msg     = line;
        ms.contact = msg->contact();
        ms.client  = msg->client();
        s_tempMsg->insert(MAP_MSG::value_type(++s_tempId, ms));
        msg->setId(s_tempId);
        return;
    }

    if (!line.isEmpty() && line.at(line.length() - 1) != '\n')
        line += '\n';

    QString name = msg->client();
    if (name.isEmpty())
        name = QString::number(msg->contact());
    QString f_name = QString(HISTORY_PATH).append(name);

    f_name = user_file(f_name);

    Contact *contact = getContacts()->contact(msg->contact());
	SIM::PropertyHubPtr data;
    if (contact)
         data = contact->getUserData("history");
    if (!data.isNull() && data->value("CutSize").toBool())
    {
        QFileInfo fInfo(f_name);
        if (fInfo.exists() && (fInfo.size() >= data->value("MaxSize").toInt() * 0x100000 + CUT_BLOCK))
        {
            int pos = fInfo.size() - data->value("MaxSize").toUInt() * 0x100000 + line.size();
            if (pos < 0)
                pos = 0;
            del(f_name, msg->contact(), pos, false);
        }
    }

    QFile f(f_name);
    if (!f.open(QIODevice::ReadWrite | QIODevice::Append))
    {
        log(L_ERROR, "Can't open %s", qPrintable(f_name));
        return;
    }
    qint64 id = f.pos();
    f.write(line);

    msg->setId(id);
}
Exemple #5
0
SoundUserConfig::SoundUserConfig(QWidget *parent, SIM::PropertyHubPtr data, SoundPlugin *plugin)
  : QWidget(parent)
  , m_plugin(plugin)
{
    setupUi(this);

    setProperty("override", data->value("sound/override").toBool());

    int row = 0;
    addRow(lstSound, row, Icon("SIM"), i18n("Online alert"), ONLINE_ALERT, data->value("sound/Alert").toString());

    // Well, basically, this mess means that core plugin shouldn't keep messageTypes
    PluginPtr coreplugin = getPluginManager()->plugin("_core");
    CorePlugin* core = static_cast<CorePlugin*>(coreplugin.data());
    CommandDef *cmd;
    CommandsMapIterator it(core->messageTypes);
    while((cmd = ++it) != NULL)
    {
        MessageDef *def = (MessageDef*)(cmd->param);
        if ((def == NULL) || (cmd->icon.isEmpty()) ||
                (def->flags & (MESSAGE_HIDDEN | MESSAGE_SENDONLY | MESSAGE_CHILD)))
		{
            continue;
		}
        if ((def->singular == NULL) || (def->plural == NULL) ||
                (*def->singular == 0) || (*def->plural == 0))
		{
            continue;
		}
        QString type = i18n(def->singular, def->plural, 1);
        int pos = type.indexOf("1 ");
        if (pos == 0){
            type = type.mid(2);
        }else if (pos > 0){
            type = type.left(pos);
        }
        type = type.left(1).toUpper() + type.mid(1);

        row++;
        addRow(lstSound, row, Icon(cmd->icon), type, cmd->id, m_plugin->messageSound(cmd->id, data->value("id").toUInt()));
    }
    chkActive->setChecked(data->value("sound/NoSoundIfActive").toBool());
    chkDisable->setChecked(data->value("sound/Disable").toBool());
    connect(chkDisable, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
    toggled(data->value("sound/Disable").toBool());
    lstSound->resizeColumnsToContents();
    lstSound->setItemDelegate(new EditSoundDelegate(1, lstSound));
    lstSound->sortByColumn(0, Qt::AscendingOrder);
}
Exemple #6
0
void OSDWidget::showOSD(const QString &str, SIM::PropertyHubPtr data)
{
	currentData = data;
    m_bFading = data->value("Fading").toBool();
    m_sText = str;
    if (isScreenSaverActive())
    {
        hide();
        return;
    }
    m_text_y = 0;
    m_bBackground = data->value("Background").toBool();
    m_bShadow = data->value("Shadow").toBool();

    setFont(FontEdit::str2font(data->value("Font").toString(), baseFont));

    //int SHADOW_OFFS = SHADOW_DEF;

    recalcGeometry();
    resize(m_Rect.size());

    QImage image(size(),QImage::Format_ARGB32);
    image.fill(Qt::transparent);

    QPainter p(&image);
    p.setRenderHints(QPainter::HighQualityAntialiasing|QPainter::TextAntialiasing|QPainter::Antialiasing);
    draw(p);
    p.end();
    setPixmap(QPixmap::fromImage(image));
    if (m_bFading)
        setMask(QPixmap::fromImage(image.createAlphaMask(), Qt::MonoOnly));

    transCounter = 0;
    transCounterDelta = cTCD;
    setWindowOpacity(transCounter/100.);

    QLabel::show();
    raise();
    
    if (m_bFading)
        m_transTimer.start(cFadeTime);

}
	void Test::userDataManipulation()
	{
		SIM::UserDataPtr data = SIM::UserData::create();
		SIM::PropertyHubPtr hub = data->getUserData("nonexistant");
		QVERIFY(hub.isNull());
		
		hub = data->createUserData("alpha");
		QVERIFY(!hub.isNull());
		hub->setValue("foo", 12);
		QCOMPARE(hub->value("foo").toInt(), 12);

		SIM::PropertyHubPtr anotherhub = data->getUserData("alpha");
		QCOMPARE(anotherhub->value("foo").toInt(), 12);

		hub.clear();
		anotherhub.clear();
		data->destroyUserData("alpha");
		hub = data->getUserData("alpha");
		QVERIFY(hub.isNull());
	}
Exemple #8
0
FileConfig::FileConfig(QWidget *parent, SIM::PropertyHubPtr data)
  : QWidget(parent)
{
    setupUi(this);
    edtPath->setDirMode(true);
    edtPath->setText(user_file(data->value("IncomingPath").toString()));
    switch (data->value("AcceptMode").toUInt())
    {
    case 0:
        btnDialog->setChecked(true);
        break;
    case 1:
        btnAccept->setChecked(true);
        chkOverwrite->setEnabled(true);
        break;
    case 2:
        btnDecline->setChecked(true);
        edtDecline->setEnabled(true);
        break;
    }
    chkOverwrite->setChecked(data->value("OverwriteFiles").toBool());
    edtDecline->setPlainText(data->value("DeclineMessage").toString());
}
Exemple #9
0
void FileConfig::apply(SIM::PropertyHubPtr data)
{
    QString def = edtPath->text().isEmpty() ? "Incoming Files" : edtPath->text();
    data->setValue("IncomingPath", def);
    edtPath->setText(user_file(data->value("IncomingPath").toString()));
    data->setValue("AcceptMode", 0);
    if (btnAccept->isChecked())
    {
        data->setValue("AcceptMode", 1);
        data->setValue("OverwriteFiles", chkOverwrite->isChecked());
    }
    if (btnDecline->isChecked())
    {
        data->setValue("AcceptMode", 2);
        data->setValue("DeclineMessage", edtDecline->toPlainText());
    }
}
Exemple #10
0
void MessageConfig::apply(SIM::PropertyHubPtr _data)
{
    if (m_file)
        m_file->apply(_data);

	SIM::PropertyHubPtr data = _data;
    data->setValue("OpenOnOnline", chkOnline->isChecked());
    data->setValue("LogStatus", chkStatus->isChecked());
    data->setValue("OpenNewMessage", NEW_MSG_NOOPEN);
    if (btnMinimize->isChecked())
        data->setValue("OpenNewMessage", NEW_MSG_MINIMIZE);
    if (btnRaise->isChecked())
        data->setValue("OpenNewMessage", NEW_MSG_RAISE);
}
Exemple #11
0
bool OSDPlugin::processEvent(Event *e)
{
    OSDRequest osd;
    switch (e->type()){
    case eEventContact: {
        EventContact *ec = static_cast<EventContact*>(e);
        Contact *contact = ec->contact();
        if (contact->getIgnore())
            break;
        switch(ec->action()) {
        case EventContact::eOnline: {
            osd.contact = contact->id();
            osd.type    = OSD_ALERTONLINE;
            m_queue.push_back(osd);
            processQueue();
            break;
        }
        case EventContact::eStatus:
		{
			SIM::PropertyHubPtr data = contact->getUserData("OSD");
            if(!data.isNull()) {
                unsigned style = 0;
                QSet<QString> wrkIcons;
                QString statusIcon;
                contact->contactInfo(style, statusIcon, &wrkIcons);
                if (wrkIcons.contains("typing")){
                    if (!m_typing.contains(contact->id())) {
                        m_typing += contact->id();
                        osd.contact = contact->id();
                        osd.type    = OSD_TYPING;
                        m_queue.push_back(osd);
                        processQueue();
                    }
                }else{
                    m_typing.remove(contact->id());
                    if ((m_request.type == OSD_TYPING) && (m_request.contact == contact->id())){
                        m_timer->stop(); bTimerActive=false;
                        m_timer->start(100); bTimerActive=true;
                    }
                }
            }
            break;
        }
        default:
            break;
        }
        break;
    }
    case eEventMessageReceived:
    {
        EventMessage *em = static_cast<EventMessage*>(e);
        Message *msg = em->msg();
        Contact *contact = getContacts()->contact(msg->contact());
        if (contact == NULL)
            break;
		SIM::PropertyHubPtr data = contact->getUserData("OSD");
        if(data.isNull())
            break;
        osd.contact = msg->contact();
        CorePlugin* core = GET_CorePlugin();
        if (!core->unread.empty())
            bHaveUnreadMessages=true;
        if (msg->type() == MessageStatus) {
            StatusMessage *smsg = (StatusMessage*)msg;
            switch (smsg->getStatus()) {
            case STATUS_AWAY:
                osd.type = OSD_ALERTAWAY;
                break;
            case STATUS_NA:
                osd.type = OSD_ALERTNA;
                break;
            case STATUS_DND:
                osd.type = OSD_ALERTDND;
                break;
            case STATUS_OCCUPIED:    /* STATUS_OCCUPIED, took over from contacts.h! */
                osd.type = OSD_ALERTOCCUPIED;
                break;
            case STATUS_FFC:
                osd.type = OSD_ALERTFFC;
                break;
            case STATUS_OFFLINE:
                osd.type = OSD_ALERTOFFLINE;
                break;
            case STATUS_ONLINE:
                osd.type = OSD_NONE;
                return false;
            default:
                log(L_DEBUG,"OSD: Unknown status %ld",smsg->getStatus());
                osd.type = OSD_NONE;
                return false;
            }
            m_queue.push_back(osd);
            processQueue();
        }else{
            osd.type    = OSD_MESSAGE;
            if ((m_request.type == OSD_MESSAGE) && (m_request.contact == msg->contact())){
                m_queue.push_front(osd);
                m_timer->stop();    bTimerActive=false;
                m_timer->start(100);bTimerActive=true;
            }else{
                m_queue.push_back(osd);
                processQueue();
            }
        }
        break;
    }
    case eEventMessageDeleted:
    case eEventMessageRead: {
        EventMessage *em = static_cast<EventMessage*>(e);
        Message *msg = em->msg();
        Contact *contact = getContacts()->contact(msg->contact());
        if (contact == NULL)
            break;
		SIM::PropertyHubPtr data = contact->getUserData("OSD");
        if (data.isNull())
            break;
        osd.contact = msg->contact();
        CorePlugin* core = GET_CorePlugin();
        if (core->unread.empty())
	    bHaveUnreadMessages=false;
        if (msg->type() == MessageStatus) {
            StatusMessage *smsg = (StatusMessage*)msg;
            switch (smsg->getStatus()) {
            case STATUS_AWAY:
                osd.type = OSD_ALERTAWAY;
                break;
            case STATUS_NA:
                osd.type = OSD_ALERTNA;
                break;
            case STATUS_DND:
                osd.type = OSD_ALERTDND;
                break;
            case STATUS_OCCUPIED:    /* STATUS_OCCUPIED, took over from contacts.h! */
                osd.type = OSD_ALERTOCCUPIED;
                break;
            case STATUS_FFC:
                osd.type = OSD_ALERTFFC;
                break;
            case STATUS_OFFLINE:
                osd.type = OSD_ALERTOFFLINE;
                break;
            case STATUS_ONLINE:
                osd.type = OSD_NONE;
                return false;
            default:
                log(L_DEBUG,"OSD: Unknown status %ld",smsg->getStatus());
                osd.type = OSD_NONE;
                return false;
            }
            m_queue.push_back(osd);
            processQueue();
        }else{
            osd.type    = OSD_MESSAGE;
            if ((m_request.type == OSD_MESSAGE) && (m_request.contact == msg->contact())){
                m_queue.push_front(osd);
                m_timer->stop();    bTimerActive=false;
                m_timer->start(100);bTimerActive=true;
            }else{
                m_queue.push_back(osd);
                processQueue();
            }
        }
        break;
    }
    default:
        break;
    }
    return false;
}
Exemple #12
0
void OSDPlugin::processQueue()
{
    if (bTimerActive /*m_timer->isActive()*/) //Due to a f*****g bug in QTimer::isActive()
        return;
    while (m_queue.size()){
        m_request = m_queue.takeFirst();
        Contact *contact = getContacts()->contact(m_request.contact);
        if ((contact == NULL) || contact->getIgnore())
            continue;
        QString text;
        SIM::PropertyHubPtr data = contact->getUserData("OSD");
		uint ms = STATUS_ONLINE;
        switch (m_request.type){
        case OSD_ALERTONLINE:
            if (data->value("EnableAlert").toBool() && data->value("EnableAlertOnline").toBool()){
                unsigned style = 0;
                QString statusIcon;
                if (contact->contactInfo(style, statusIcon) == STATUS_ONLINE)
                    text = g_i18n("%1 is online", contact) .arg(contact->getName());
            }
            break;
        case OSD_ALERTAWAY:
            if (data->value("EnableAlert").toBool() && data->value("EnableAlertAway").toBool()){
                text = g_i18n("%1 is away", contact) .arg(contact->getName());
            }
            break;
        case OSD_ALERTNA:
            if (data->value("EnableAlert").toBool() && data->value("EnableAlertNA").toBool()){
                text = g_i18n("%1 is not available", contact) .arg(contact->getName());
            }
            break;
        case OSD_ALERTDND:
            if (data->value("EnableAlert").toBool() && data->value("EnableAlertDND").toBool()){
                text = g_i18n("%1 doesn't want to be disturbed", contact) .arg(contact->getName());
            }
            break;
        case OSD_ALERTOCCUPIED:
            if (data->value("EnableAlert").toBool() && data->value("EnableAlertOccupied").toBool()){
                text = g_i18n("%1 is occupied", contact) .arg(contact->getName());
            }
            break;
        case OSD_ALERTFFC:
            if (data->value("EnableAlert").toBool() && data->value("EnableAlertFFC").toBool()){
                text = g_i18n("%1 is free for chat", contact) .arg(contact->getName());
            }
            break;
        case OSD_ALERTOFFLINE:
            if (data->value("EnableAlert").toBool() && data->value("EnableAlertOffline").toBool() && (ms-1) ){
                text = g_i18n("%1 is offline", contact) .arg(contact->getName());
            }
            break;
        case OSD_TYPING:
            if (data->value("EnableTyping").toBool()){
                unsigned style = 0;
                QSet<QString> wrkIcons;
                QString statusIcon;
                contact->contactInfo(style, statusIcon, &wrkIcons);
                if (wrkIcons.contains("typing"))
                    text = g_i18n("%1 is typing", contact) .arg(contact->getName());
            }
            break;
        case OSD_MESSAGE:
/*            if (data->EnableMessage.toBool() && core ){
 *                 list<msg_id>::iterator it;
 *                 TYPE_MAP types;
 *                 TYPE_MAP::iterator itc;
 *                 QString msg_text;
 *                 for (it = core->unread.begin(); it != core->unread.end(); ++it){
 *                     if (it->contact != m_request.contact)
 *                         continue;
 *                     unsigned type = it->type;
 *                     itc = types.find(type);
 *                     if (itc == types.end()){
 *                         types.insert(TYPE_MAP::value_type(type, 1));
 *                     }else{
 *                         (*itc).second++;
 *                     }
 *                     if (!data->EnableMessageShowContent.toBool())
 *                         continue;
 *                     EventLoadMessage e(it->id, it->client, it->contact);
 *                     e.process();
 *                     Message *msg = e.message();
 *                     if (msg == NULL)
 *                         continue;
 *                     QString msgText = msg->getPlainText().trimmed();
 *                     if (msgText.isEmpty())
 *                         continue;
 *                     if (!msg_text.isEmpty())
 *                         msg_text += "\n";
 *                     msg_text += msgText;
 *                 }
 *                 if (types.empty())
 *                     break;
 *                 for (itc = types.begin(); itc != types.end(); ++itc){
 *                     CommandDef *def = core->messageTypes.find((*itc).first);
 *                     if (def == NULL)
 *                         continue;
 *                     MessageDef *mdef = (MessageDef*)(def->param);
 *                     QString msg = i18n(mdef->singular, mdef->plural, (*itc).second);
 *                     if ((*itc).second == 1){
 *                         int pos = msg.indexOf("1 ");
 *                         if (pos > 0){
 *                             msg = msg.left(pos);
 *                         }else if (pos == 0){
 *                             msg = msg.mid(2);
 *                         }
 *                         msg = msg.left(1).toUpper() + msg.mid(1);
 *                     }
 *                     if (!text.isEmpty())
 *                         text += ", ";
 *                     text += msg;
 *                 }
 * 
 *                 
 *                 if ( core->getManualStatus()==STATUS_NA && 
 *                       data->EnableCapsLockFlash.toBool() && 
 *                       ! this->isRunning() 
 *                     )
 *                     this->start(); //Start flashing the CapsLock if enabled
 *                 text = i18n("%1 from %2") .arg(text) .arg(contact->getName());
 *                 if (msg_text.isEmpty())
 *                     break;
 *                 text += ":\n";
 *                 text += msg_text;
 *             }
 */
            break;
        default:
            break;
        }
        if (!text.isEmpty()){
            if (m_osd == NULL){
                m_osd = new OSDWidget(this);
                connect(m_osd, SIGNAL(dblClick()), this, SLOT(dblClick()));
                connect(m_osd, SIGNAL(closeClick()), this, SLOT(closeClick()));
            }
            static_cast<OSDWidget*>(m_osd)->showOSD(text, data);
            m_timer->start(data->value("Timeout").toUInt() * 1000);
			bTimerActive=true; //Due to a f*****g bug in QTimer::isActive()
            return;
        }
    }
    m_timer->stop(); bTimerActive=false; //Due to a f*****g bug in QTimer::isActive()
    m_request.contact = 0;
    m_request.type = OSD_NONE;
}
Exemple #13
0
void SMSConfig::apply(SIM::PropertyHubPtr data)
{
    data->setValue("SMSSignatureBefore", edtBefore->toPlainText());
    data->setValue("SMSSignatureAfter", edtAfter->toPlainText());
}
Exemple #14
0
void OSDConfig::apply(SIM::PropertyHubPtr data)
{
    data->setValue("EnableMessage", chkMessage->isChecked());
    data->setValue("EnableMessageShowContent", chkMessageContent->isChecked());
    data->setValue("EnableCapsLockFlash", chkCapsLockFlash->isChecked());
    data->setValue("EnableAlert", chkStatus->isChecked());
    data->setValue("EnableAlertOnline", chkStatusOnline->isChecked());
    data->setValue("EnableAlertAway", chkStatusAway->isChecked());
    data->setValue("EnableAlertNA", chkStatusNA->isChecked());
    data->setValue("EnableAlertDND", chkStatusDND->isChecked());
    data->setValue("EnableAlertOccupied", chkStatusOccupied->isChecked());
    data->setValue("EnableAlertFFC", chkStatusFFC->isChecked());
    data->setValue("EnableAlertOffline", chkStatusOffline->isChecked());
    data->setValue("EnableTyping", chkTyping->isChecked());
    data->setValue("ContentLines", (uint)edtLines->text().toULong());
    m_iface->apply(data);
}
Exemple #15
0
bool ForwardPlugin::processEvent(Event *e)
{
    if (e->type() == eEventMessageReceived){
        EventMessage *em = static_cast<EventMessage*>(e);
        Message *msg = em->msg();
        if (msg->type() == MessageStatus)
            return false;
        QString text = msg->getPlainText();
        if (text.isEmpty())
            return false;
        if (msg->type() == MessageSMS){
            SMSMessage *sms = static_cast<SMSMessage*>(msg);
            QString phone = sms->getPhone();
            bool bMyPhone;
            SIM::PropertyHubPtr data = getContacts()->getUserData("forward");
            bMyPhone = ContactList::cmpPhone(phone, data->value("Phone").toString());
            if (!bMyPhone){
                Group *grp;
                ContactList::GroupIterator it;
                while ((grp = ++it) != NULL){
                    data = grp->getUserData("forward", false);
                    if (data && !data->value("Phone").toString().isEmpty()){
                        bMyPhone = ContactList::cmpPhone(phone, data->value("Phone").toString());
                        break;
                    }
                }
            }
            if (!bMyPhone){
                Contact *contact;
                ContactList::ContactIterator it;
                while ((contact = ++it) != NULL){
                    data = contact->getUserData("forward", false);
                    if (data && !data->value("Phone").toString().isEmpty())
                    {
                        bMyPhone = ContactList::cmpPhone(phone, data->value("Phone").toString());
                        break;
                    }
                }
            }
            if (bMyPhone){
                int n = text.indexOf(": ");
                if (n > 0){
                    QString name = text.left(n);
                    QString msg_text = text.mid(n + 2);
                    Contact *contact;
                    ContactList::ContactIterator it;
                    while ((contact = ++it) != NULL){
                        if (contact->getName() == name){
                            Message *msg = new Message(MessageGeneric);
                            msg->setContact(contact->id());
                            msg->setText(msg_text);
                            void *data;
                            ClientDataIterator it(contact->clientData);
                            while ((data = ++it) != NULL){
                                if (it.client()->send(msg, data))
                                    break;
                            }
                            if (data == NULL)
                                delete msg;
                            return true;
                        }
                    }
                }
            }
        }
        Contact *contact = getContacts()->contact(msg->contact());
        if (contact == NULL)
            return false;
        SIM::PropertyHubPtr data = contact->getUserData("forward");
        if (!data || data->value("Key").toString().isEmpty())
            return false;
        CorePlugin *core = GET_CorePlugin();
        unsigned status = core->getManualStatus();
        if ((status == STATUS_AWAY) || (status == STATUS_NA)){
            text = contact->getName() + ": " + text;
            unsigned flags = MESSAGE_NOHISTORY;
            if (data->value("Send1st").toBool())
                flags |= MESSAGE_1ST_PART;
            if (data->value("Translit").toBool())
                flags |= MESSAGE_TRANSLIT;
            SMSMessage *m = new SMSMessage;
            m->setPhone(data->value("Phone").toString());
            m->setText(text);
            m->setFlags(flags);
            unsigned i;
            for (i = 0; i < getContacts()->nClients(); i++){
                Client *client = getContacts()->getClient(i);
                if (client->send(m, NULL))
                    break;
            }
            if (i >= getContacts()->nClients())
                delete m;
        }
    }
    return false;
}
Exemple #16
0
OSDConfig::OSDConfig(QWidget *parent, SIM::PropertyHubPtr data, OSDPlugin *plugin)
  : QWidget(parent)
  , m_plugin(plugin)
{
    setupUi(this);
    chkMessage->setChecked(data->value("EnableMessage").toBool());
    chkMessageContent->setChecked(data->value("EnableMessageShowContent").toBool());
    chkCapsLockFlash->setChecked(data->value("EnableCapsLockFlash").toBool());
    chkStatus->setChecked(data->value("EnableAlert").toBool());
    chkStatusOnline->setChecked(data->value("EnableAlertOnline").toBool());
    chkStatusAway->setChecked(data->value("EnableAlertAway").toBool());
    chkStatusNA->setChecked(data->value("EnableAlertNA").toBool());
    chkStatusDND->setChecked(data->value("EnableAlertDND").toBool());
    chkStatusOccupied->setChecked(data->value("EnableAlertOccupied").toBool());
    chkStatusFFC->setChecked(data->value("EnableAlertFFC").toBool());
    chkStatusOffline->setChecked(data->value("EnableAlertOffline").toBool());
    chkTyping->setChecked(data->value("EnableTyping").toBool());
    for (QObject *p = parent; p != NULL; p = p->parent()){
        QTabWidget *tab = qobject_cast<QTabWidget*>(p);
        if (!tab)
            continue;
		SIM::PropertyHubPtr data = getContacts()->getUserData("OSD");
        m_iface = new OSDIface(tab, data, plugin);
        tab->addTab(m_iface, i18n("&Interface"));
        break;
    }
    edtLines->setValue(data->value("ContentLines").toUInt());
    connect(chkStatus, SIGNAL(toggled(bool)), this, SLOT(statusToggled(bool)));
    connect(chkMessage, SIGNAL(toggled(bool)), this, SLOT(showMessageToggled(bool)));
    connect(chkMessageContent, SIGNAL(toggled(bool)), this, SLOT(contentToggled(bool)));
    showMessageToggled(chkMessage->isChecked());
    contentToggled(chkMessageContent->isChecked());
    statusToggled(data->value("EnableAlert").toBool());
}
bool MsgEdit::processEvent(Event *e)
{
    switch (e->type()) {
    case eEventContact: {
        EventContact *ec = static_cast<EventContact*>(e);
        if (ec->contact()->id() != m_userWnd->m_id)
            break;
        adjustType();
        break;
    }
    case eEventClientChanged: {
        adjustType();
        break;
    }
    case eEventMessageReceived: {
        EventMessage *em = static_cast<EventMessage*>(e);
        Message *msg = em->msg();
        if (msg->getFlags() & MESSAGE_NOVIEW)
            return false;
        if ((msg->contact() == m_userWnd->id()) && (msg->type() != MessageStatus)){
            if (CorePlugin::instance()->getContainerMode()){
                bool bSetFocus = false;
                if (topLevelWidget() && topLevelWidget()->inherits("Container")){
                    Container *container = static_cast<Container*>(topLevelWidget());
                    if (container->wnd() == m_userWnd)
                        bSetFocus = true;
                }
                setMessage(msg, bSetFocus);
            }else{
                if (m_edit->isReadOnly())
                    QTimer::singleShot(0, this, SLOT(setupNext()));
            }
        }
        break;
    }
    case eEventRealSendMessage: {
        EventRealSendMessage *ersm = static_cast<EventRealSendMessage*>(e);
        if (ersm->edit() == this){
            sendMessage(ersm->msg());
            return true;
        }
        break;
    }
    case eEventCheckCommandState: {
        EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
        CommandDef *cmd = ecs->cmd();
        if ((cmd->param == (TextEdit*)m_edit) && (cmd->id == CmdTranslit)){
            Contact *contact = getContacts()->contact(m_userWnd->id());
            if (contact){
				SIM::PropertyHubPtr data = contact->getUserData("translit");
                if(!data.isNull()) {
                    cmd->flags &= ~COMMAND_CHECKED;
                    if (data->value("Translit").toBool())
                        cmd->flags |= COMMAND_CHECKED;
                    // FIXME: return true; missing here?
                }
            }
            return false;
        }
        if ((cmd->menu_id != MenuTextEdit) || (cmd->param != (TextEdit*)m_edit))
            return false;
        cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED);
        switch (cmd->id){
        case CmdUndo:
            if (m_edit->isReadOnly())
                return false;
            if (!m_edit->document()->isUndoAvailable())
                cmd->flags |= COMMAND_DISABLED;
            return true;
        case CmdRedo:
            if (m_edit->isReadOnly())
                return false;
            if (!m_edit->document()->isRedoAvailable())
                cmd->flags |= COMMAND_DISABLED;
            return true;
        case CmdCut:
            if (m_edit->isReadOnly())
                return false;
        case CmdCopy:
            if (m_edit->textCursor().selectedText().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return true;
        case CmdPaste:
            if (m_edit->isReadOnly())
                return false;
            if (QApplication::clipboard()->text().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return true;
        case CmdClear:
            if (m_edit->isReadOnly())
                return false;
        case CmdSelectAll:
            if (m_edit->toPlainText().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return true;
        }
        break;
    }
    case eEventCommandExec: {
        EventCommandExec *ece = static_cast<EventCommandExec*>(e);
        CommandDef *cmd = ece->cmd();
#if defined(USE_KDE)
#if KDE_IS_VERSION(3,2,0)
        if (cmd->id == CmdEnableSpell){
            m_edit->setCheckSpellingEnabled(cmd->flags & COMMAND_CHECKED);
            return false;
        }
        else if ((cmd->id == CmdSpell) && (cmd->param == this)){
            m_edit->checkSpelling();
            return true;
        }
        else
#endif
#endif
        if ((cmd->id == CmdSmile) && (cmd->param == this)){
            EventCommandWidget eWidget(cmd);
            eWidget.process();
            QToolButton *btnSmile = qobject_cast<QToolButton*>(eWidget.widget());
            if (btnSmile){
                SmilePopup *popup = new SmilePopup(this);
                connect(popup, SIGNAL(insert(const QString &)), this, SLOT(insertSmile(const QString &)));
                QPoint p = CToolButton::popupPos(btnSmile, popup);
                popup->move(p);
                popup->show();
            }
            return true;
        }
        else if ((cmd->id == CmdTranslit) && (cmd->param == this)){
            Contact *contact = getContacts()->contact(m_userWnd->id());
            if (contact){
				SIM::PropertyHubPtr data = contact->getUserData("translit", true);
                data->setValue("Translit", ((cmd->flags & COMMAND_CHECKED) != 0));
            }
            return true;
        }
        else if ((cmd->id == CmdMultiply) && (cmd->param == this)){
            m_userWnd->showListView((cmd->flags & COMMAND_CHECKED) != 0);
            return true;
        }
        else if ((cmd->bar_id == ToolBarMsgEdit) && m_edit->isReadOnly() && (cmd->param == this)){
            switch (cmd->id){
            case CmdMsgAnswer:{
                    Message *msg = new Message(MessageGeneric);
                    msg->setContact(m_userWnd->id());
                    msg->setClient(m_client);
                    EventOpenMessage(msg).process();
                    delete msg;
                }
            case CmdNextMessage:
                QTimer::singleShot(0, this, SLOT(goNext()));
                break;
            }
        }
        else if ((cmd->menu_id != MenuTextEdit) || (cmd->param != this))
            return false;
        switch (cmd->id){
        case CmdUndo:
            m_edit->undo();
            return true;
        case CmdRedo:
            m_edit->redo();
            return true;
        case CmdCut:
            m_edit->cut();
            return true;
        case CmdCopy:
            m_edit->copy();
            return true;
        case CmdPaste:
            m_edit->paste();
            return true;
        case CmdClear:
            m_edit->clear();
            return true;
        case CmdSelectAll:
            m_edit->selectAll();
            return true;
        }
        break;
    }
bool MsgEdit::sendMessage(Message *msg)
{
    if (m_retry.msg){
        delete m_retry.msg;
        m_retry.msg = NULL;
    }
    if (m_msg){
        delete msg;
        if (EventMessageCancel(m_msg).process())
            m_msg = NULL;
        stopSend(false);
        return false;
    }
    bool bClose = true;
    if (CorePlugin::instance()->getContainerMode()){
        bClose = false;
        Command cmd;
        cmd->id		= CmdSendClose;
        cmd->param	= this;
        EventCommandWidget eWidget(cmd);
        eWidget.process();
        QToolButton *btnClose = qobject_cast<QToolButton*>(eWidget.widget());
        if (btnClose)
            bClose = btnClose->isChecked();
    }
    CorePlugin::instance()->setValue("CloseSend", bClose);

    Contact *contact = getContacts()->contact(m_userWnd->id());
    if (contact){
		SIM::PropertyHubPtr data = contact->getUserData("translit");
        if (!data.isNull() && data->value("Translit").toBool())
            msg->setFlags(msg->getFlags() | MESSAGE_TRANSLIT);
    }

    msg->setFlags(msg->getFlags() | m_flags);
    m_flags = 0;

    if (m_userWnd->m_list){
        if( !m_userWnd->m_list->isHaveSelected() )
            return false;
        multiply = m_userWnd->m_list->selected();
        msg->setContact( multiply.first() );
        multiply.pop_front();
        msg->setClient(NULL);
        if( multiply.count() > 0 )
            msg->setFlags(msg->getFlags() | MESSAGE_MULTIPLY);
    }else if (!m_resource.isEmpty()){
        void *data = NULL;
        Client *c = client(data, true, false, msg->contact(), true);
        if (c){
            QString resources = c->resources(data);
            while (!resources.isEmpty()){
                QString res = getToken(resources, ';');
                getToken(res, ',');
                if (m_resource == res){
                    msg->setResource(m_resource);
                    break;
                }
            }
        }
    }

    editLostFocus();
    Command cmd;
    cmd->id		= CmdSend;
    cmd->text	= I18N_NOOP("Cancel");
    cmd->icon	= "cancel";
    cmd->flags	= BTN_PICT;
    cmd->param	= this;
    EventCommandChange(cmd).process();
    m_msg = msg;
    return send();
}
Exemple #19
0
SMSConfig::SMSConfig(QWidget *parent, SIM::PropertyHubPtr data) : QWidget(parent)
{
	setupUi(this);
    edtBefore->setPlainText(data->value("SMSSignatureBefore").toString());
    edtAfter->setPlainText(data->value("SMSSignatureAfter").toString());
}