本文整理汇总了C++中Contact::getUserData方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::getUserData方法的具体用法?C++ Contact::getUserData怎么用?C++ Contact::getUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::getUserData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processQueue
void OSDPlugin::processQueue()
{
if (bTimerActive /*m_timer->isActive()*/) //Due to a fucking 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){
//.........这里部分代码省略.........
示例2: processEvent
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{
//.........这里部分代码省略.........
示例3: e
MsgSMS::MsgSMS(CToolCustom *parent, Message *msg)
: QComboBox(parent)
{
for (QWidget *p = parent->parentWidget(); p; p = p->parentWidget()){
if (p->inherits("MsgEdit")){
m_edit = static_cast<MsgEdit*>(p);
break;
}
}
m_bExpand = false;
QString t = msg->getPlainText();
if (!t.isEmpty())
m_edit->m_edit->setText(t);
m_panel = NULL;
setEditable(true);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
parent->addWidget(this);
btnTranslit = new QToolButton(parent);
btnTranslit->setIconSet(*Icon("translit"));
btnTranslit->setTextLabel(i18n("Send in translit"));
btnTranslit->setToggleButton(true);
parent->addWidget(btnTranslit);
btnTranslit->show();
parent->setText(i18n("Phone:"));
m_edit->m_edit->setTextFormat(PlainText);
Command cmd;
cmd->id = CmdSend;
cmd->param = m_edit;
Event e(EventCommandWidget, cmd);
btnSend = (QToolButton*)(e.process());
connect(lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&)));
connect(m_edit->m_edit, SIGNAL(textChanged()), this, SLOT(textChanged()));
connect(btnTranslit, SIGNAL(toggled(bool)), this, SLOT(translitToggled(bool)));
Contact *contact = getContacts()->contact(msg->contact());
if (contact == NULL)
return;
SMSUserData *data = (SMSUserData*)(contact->getUserData(CorePlugin::m_plugin->sms_data_id));
btnTranslit->setOn(data->SMSTranslit);
QString phones = contact->getPhones();
while (phones.length()){
QString phoneItem = getToken(phones, ';', false);
phoneItem = getToken(phoneItem, '/', false);
QString phone = getToken(phoneItem, ',');
getToken(phoneItem, ',');
if (phoneItem.toUInt() == CELLULAR)
insertItem(phone);
}
t = static_cast<SMSMessage*>(msg)->getPhone();
if (!t.isEmpty())
lineEdit()->setText(t);
textChanged();
if (contact->getTemporary()){
m_panel = new SMSPanel(m_edit->m_frame);
m_edit->m_layout->insertWidget(0, m_panel);
connect(m_panel, SIGNAL(destroyed()), this, SLOT(panelDestroyed()));
m_panel->show();
}
if (m_edit->m_edit->text().isEmpty()){
TemplateExpand t;
if (data->SMSSignatureBefore){
t.tmpl = QString::fromUtf8(data->SMSSignatureBefore);
t.contact = contact;
t.receiver = this;
t.param = NULL;
Event eTmpl(EventTemplateExpand, &t);
eTmpl.process();
}else{
m_bExpand = true;
if (data->SMSSignatureAfter){
t.tmpl = QString::fromUtf8(data->SMSSignatureAfter);
t.contact = contact;
t.receiver = this;
t.param = NULL;
Event eTmpl(EventTemplateExpand, &t);
eTmpl.process();
}
}
}
show();
}
示例4: sendMessage
bool MsgEdit::sendMessage(Message *msg)
{
if (m_retry.msg){
delete m_retry.msg;
m_retry.msg = NULL;
}
if (m_msg){
delete msg;
Event e(EventMessageCancel, m_msg);
if (e.process())
m_msg = NULL;
stopSend(false);
return false;
}
bool bClose = true;
if (CorePlugin::m_plugin->getContainerMode()){
bClose = false;
Command cmd;
cmd->id = CmdSendClose;
cmd->param = this;
Event e(EventCommandWidget, cmd);
QToolButton *btnClose = (QToolButton*)(e.process());
if (btnClose)
bClose = btnClose->isOn();
}
CorePlugin::m_plugin->setCloseSend(bClose);
Contact *contact = getContacts()->contact(m_userWnd->id());
if (contact){
TranslitUserData *data = (TranslitUserData*)(contact->getUserData(CorePlugin::m_plugin->translit_data_id));
if (data && data->Translit)
msg->setFlags(msg->getFlags() | MESSAGE_TRANSLIT);
}
msg->setFlags(msg->getFlags() | m_flags);
m_flags = 0;
if (m_userWnd->m_list){
multiply = m_userWnd->m_list->selected;
if (multiply.empty())
return false;
multiply_it = multiply.begin();
msg->setContact(*multiply_it);
msg->setClient(NULL);
++multiply_it;
if (multiply_it != multiply.end())
msg->setFlags(msg->getFlags() | MESSAGE_MULTIPLY);
}
editLostFocus();
Command cmd;
cmd->id = CmdSend;
cmd->text = I18N_NOOP("Cancel");
cmd->icon = "cancel";
cmd->flags = BTN_PICT;
cmd->param = this;
Event eCmd(EventCommandChange, cmd);
eCmd.process();
m_msg = msg;
return send();
}
示例5: processEvent
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){
//.........这里部分代码省略.........
示例6: eBtn
void *MsgEdit::processEvent(Event *e)
{
if ((e->type() == EventContactChanged) && (((Contact*)(e->param()))->id() == m_userWnd->m_id)){
adjustType();
return NULL;
}
if (e->type() == EventClientChanged){
adjustType();
return NULL;
}
if (e->type() == EventMessageReceived){
Message *msg = (Message*)(e->param());
if (msg->getFlags() & MESSAGE_NOVIEW)
return NULL;
if ((msg->contact() == m_userWnd->id()) && (msg->type() != MessageStatus)){
if (CorePlugin::m_plugin->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()));
}
}
}
if (e->type() == EventRealSendMessage){
MsgSend *s = (MsgSend*)(e->param());
if (s->edit == this){
sendMessage(s->msg);
return e->param();
}
}
if (e->type() == EventCheckState){
CommandDef *cmd = (CommandDef*)(e->param());
if ((cmd->param == this) && (cmd->id == CmdTranslit)){
Contact *contact = getContacts()->contact(m_userWnd->id());
if (contact){
TranslitUserData *data = (TranslitUserData*)(contact->getUserData(CorePlugin::m_plugin->translit_data_id));
if (data){
cmd->flags &= ~COMMAND_CHECKED;
if (data->Translit.bValue)
cmd->flags |= COMMAND_CHECKED;
}
}
return NULL;
}
if ((cmd->menu_id != MenuTextEdit) || (cmd->param != this))
return NULL;
cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED);
switch (cmd->id){
case CmdUndo:
if (m_edit->isReadOnly())
return NULL;
if (!m_edit->isUndoAvailable())
cmd->flags |= COMMAND_DISABLED;
return e->param();
case CmdRedo:
if (m_edit->isReadOnly())
return NULL;
if (!m_edit->isRedoAvailable())
cmd->flags |= COMMAND_DISABLED;
return e->param();
case CmdCut:
if (m_edit->isReadOnly())
return NULL;
case CmdCopy:
if (!m_edit->hasSelectedText())
cmd->flags |= COMMAND_DISABLED;
return e->param();
case CmdPaste:
if (m_edit->isReadOnly())
return NULL;
if (QApplication::clipboard()->text().isEmpty())
cmd->flags |= COMMAND_DISABLED;
return e->param();
case CmdClear:
if (m_edit->isReadOnly())
return NULL;
case CmdSelectAll:
if (m_edit->text().isEmpty())
cmd->flags |= COMMAND_DISABLED;
return e->param();
}
return NULL;
}
if (e->type() == EventCommandExec){
CommandDef *cmd = (CommandDef*)(e->param());
#if defined(USE_KDE)
#if KDE_IS_VERSION(3,2,0)
if (cmd->id == CmdEnableSpell){
m_edit->setCheckSpellingEnabled(cmd->flags & COMMAND_CHECKED);
return NULL;
}
if ((cmd->id == CmdSpell) && (cmd->param == this)){
m_edit->checkSpelling();
return e->param();
//.........这里部分代码省略.........
示例7: processQueue
void OSDPlugin::processQueue()
{
if (m_timer->isActive())
return;
while (queue.size()){
m_request = queue.front();
queue.erase(queue.begin());
Contact *contact = getContacts()->contact(m_request.contact);
if ((contact == NULL) || contact->getIgnore()){
continue;
}
QString text;
OSDUserData *data = NULL;
data = (OSDUserData*)contact->getUserData(user_data_id);
uint ms=core->getManualStatus();
switch (m_request.type){
case OSD_ALERTONLINE:
if (data->EnableAlert.toBool() && data->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->EnableAlert.toBool() && data->EnableAlertAway.toBool()){
text = g_i18n("%1 is away", contact) .arg(contact->getName());
}
break;
case OSD_ALERTNA:
if (data->EnableAlert.toBool() && data->EnableAlertNA.toBool()){
text = g_i18n("%1 is not available", contact) .arg(contact->getName());
}
break;
case OSD_ALERTDND:
if (data->EnableAlert.toBool() && data->EnableAlertDND.toBool()){
text = g_i18n("%1 doesn't want to be disturbed", contact) .arg(contact->getName());
}
break;
case OSD_ALERTOCCUPIED:
if (data->EnableAlert.toBool() && data->EnableAlertOccupied.toBool()){
text = g_i18n("%1 is occupied", contact) .arg(contact->getName());
}
break;
case OSD_ALERTFFC:
if (data->EnableAlert.toBool() && data->EnableAlertFFC.toBool()){
text = g_i18n("%1 is free for chat", contact) .arg(contact->getName());
}
break;
case OSD_ALERTOFFLINE:
if (data->EnableAlert.toBool() && data->EnableAlertOffline.toBool() && (ms-1) ){
text = g_i18n("%1 is offline", contact) .arg(contact->getName());
}
break;
case OSD_TYPING:
if (data->EnableTyping.toBool()){
unsigned style = 0;
QString wrkIcons;
QString statusIcon;
contact->contactInfo(style, statusIcon, &wrkIcons);
bool bTyping = false;
while (!wrkIcons.isEmpty()){
if (getToken(wrkIcons, ',') == "typing"){
bTyping = true;
break;
}
}
if (bTyping)
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().stripWhiteSpace();
if (msgText.isEmpty())
continue;
if (!msg_text.isEmpty())
msg_text += "\n";
msg_text += msgText;
//.........这里部分代码省略.........
示例8: processEvent
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;
queue.push_back(osd);
processQueue();
break;
}
case EventContact::eStatus: {
OSDUserData *data = (OSDUserData*)(contact->getUserData(user_data_id));
if (data){
unsigned style = 0;
QString wrkIcons;
QString statusIcon;
contact->contactInfo(style, statusIcon, &wrkIcons);
bool bTyping = false;
while (!wrkIcons.isEmpty()){
if (getToken(wrkIcons, ',') == "typing"){
bTyping = true;
break;
}
}
if (bTyping){
list<unsigned>::iterator it;
for (it = typing.begin(); it != typing.end(); ++it)
if ((*it) == contact->id())
break;
if (it == typing.end()){
typing.push_back(contact->id());
osd.contact = contact->id();
osd.type = OSD_TYPING;
queue.push_back(osd);
processQueue();
}
}else{
list<unsigned>::iterator it;
for (it = typing.begin(); it != typing.end(); ++it)
if ((*it) == contact->id())
break;
if (it != typing.end())
typing.erase(it);
if ((m_request.type == OSD_TYPING) && (m_request.contact == contact->id())){
m_timer->stop();
m_timer->start(100);
}
}
}
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;
OSDUserData *data = (OSDUserData*)(contact->getUserData(user_data_id));
if (data == NULL)
break;
osd.contact = msg->contact();
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:
//.........这里部分代码省略.........
示例9: processEvent
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;
}
示例10: switch
void *OSDPlugin::processEvent(Event *e)
{
OSDRequest osd;
Contact *contact;
Message *msg;
OSDUserData *data;
switch (e->type()){
case EventContactOnline:
contact = (Contact*)(e->param());
if (contact->getIgnore()) break;
osd.contact = contact->id();
osd.type = OSD_ALERTONLINE;
queue.push_back(osd);
processQueue();
break;
case EventMessageDeleted:
case EventMessageRead:
case EventMessageReceived:
msg = (Message*)(e->param());
contact = getContacts()->contact(msg->contact());
if (contact == NULL)
break;
data = (OSDUserData*)(contact->getUserData(user_data_id));
if (data == NULL)
break;
osd.contact = msg->contact();
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 100: /* STATUS_OCCUPIED, but defined in icqclient.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 NULL;
default:
log(L_DEBUG,"OSD: Unknown status %ld",smsg->getStatus());
osd.type = OSD_NONE;
return NULL;
}
queue.push_back(osd);
processQueue();
}else{
osd.type = OSD_MESSAGE;
if ((m_request.type == OSD_MESSAGE) && (m_request.contact == msg->contact())){
queue.push_front(osd);
m_timer->stop();
m_timer->start(100);
}else{
queue.push_back(osd);
processQueue();
}
}
break;
case EventContactStatus:
contact = (Contact*)(e->param());
if (contact->getIgnore()) break;
data = (OSDUserData*)(contact->getUserData(user_data_id));
if (data){
unsigned style = 0;
string wrkIcons;
const char *statusIcon = NULL;
contact->contactInfo(style, statusIcon, &wrkIcons);
bool bTyping = false;
while (!wrkIcons.empty()){
if (getToken(wrkIcons, ',') == "typing"){
bTyping = true;
break;
}
}
if (bTyping){
list<unsigned>::iterator it;
for (it = typing.begin(); it != typing.end(); ++it)
if ((*it) == contact->id())
break;
if (it == typing.end()){
typing.push_back(contact->id());
osd.contact = contact->id();
osd.type = OSD_TYPING;
queue.push_back(osd);
processQueue();
}
}else{
list<unsigned>::iterator it;
for (it = typing.begin(); it != typing.end(); ++it)
//.........这里部分代码省略.........
示例11: processEvent
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");
//.........这里部分代码省略.........
示例12: processEvent
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);
//.........这里部分代码省略.........
示例13: sendMessage
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();
}
示例14: it
void *ForwardPlugin::processEvent(Event *e)
{
if (e->type() == EventMessageReceived){
Message *msg = (Message*)(e->param());
if (msg->type() == MessageStatus)
return NULL;
QString text = msg->getPlainText();
if (text.isEmpty())
return NULL;
if (msg->type() == MessageSMS){
SMSMessage *sms = static_cast<SMSMessage*>(msg);
QString phone = sms->getPhone();
bool bMyPhone = false;
ForwardUserData *data = (ForwardUserData*)(getContacts()->getUserData(user_data_id));
if (data->Phone.ptr)
bMyPhone = ContactList::cmpPhone(phone.utf8(), data->Phone.ptr);
if (!bMyPhone){
Group *grp;
ContactList::GroupIterator it;
while ((grp = ++it) != NULL){
data = (ForwardUserData*)(grp->userData.getUserData(user_data_id, false));
if (data && data->Phone.ptr){
bMyPhone = ContactList::cmpPhone(phone.utf8(), data->Phone.ptr);
break;
}
}
}
if (!bMyPhone){
Contact *contact;
ContactList::ContactIterator it;
while ((contact = ++it) != NULL){
data = (ForwardUserData*)(contact->userData.getUserData(user_data_id, false));
if (data && data->Phone.ptr){
bMyPhone = ContactList::cmpPhone(phone.utf8(), data->Phone.ptr);
break;
}
}
}
if (bMyPhone){
int n = text.find(": ");
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 e->param();
}
}
}
}
}
Contact *contact = getContacts()->contact(msg->contact());
if (contact == NULL)
return NULL;
ForwardUserData *data = (ForwardUserData*)(contact->getUserData(user_data_id));
if ((data == NULL) || (data->Phone.ptr == NULL) || (*data->Phone.ptr == 0))
return NULL;
unsigned status = core->getManualStatus();
if ((status == STATUS_AWAY) || (status == STATUS_NA)){
text = contact->getName() + ": " + text;
unsigned flags = MESSAGE_NOHISTORY;
if (data->Send1st.bValue)
flags |= MESSAGE_1ST_PART;
if (data->Translit.bValue)
flags |= MESSAGE_TRANSLIT;
SMSMessage *m = new SMSMessage;
m->setPhone(QString::fromUtf8(data->Phone.ptr));
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 NULL;
}
示例15: sendMessage
bool MsgEdit::sendMessage(Message *msg)
{
if (m_retry.msg){
delete m_retry.msg;
m_retry.msg = NULL;
}
if (m_msg){
delete msg;
Event e(EventMessageCancel, m_msg);
if (e.process())
m_msg = NULL;
stopSend(false);
return false;
}
bool bClose = true;
if (CorePlugin::m_plugin->getContainerMode()){
bClose = false;
Command cmd;
cmd->id = CmdSendClose;
cmd->param = this;
Event e(EventCommandWidget, cmd);
QToolButton *btnClose = (QToolButton*)(e.process());
if (btnClose)
bClose = btnClose->isOn();
}
CorePlugin::m_plugin->setCloseSend(bClose);
Contact *contact = getContacts()->contact(m_userWnd->id());
if (contact){
TranslitUserData *data = (TranslitUserData*)(contact->getUserData(CorePlugin::m_plugin->translit_data_id));
if (data && data->Translit.bValue)
msg->setFlags(msg->getFlags() | MESSAGE_TRANSLIT);
}
msg->setFlags(msg->getFlags() | m_flags);
m_flags = 0;
if (m_userWnd->m_list){
multiply = m_userWnd->m_list->selected;
if (multiply.empty())
return false;
multiply_it = multiply.begin();
msg->setContact(*multiply_it);
msg->setClient(NULL);
++multiply_it;
if (multiply_it != multiply.end())
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){
string resources = c->resources(data);
while (!resources.empty()){
string res = getToken(resources, ';');
getToken(res, ',');
if (m_resource == QString::fromUtf8(res.c_str())){
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;
Event eCmd(EventCommandChange, cmd);
eCmd.process();
m_msg = msg;
return send();
}