GpgGen::GpgGen(GpgCfg *cfg) : GpgGenBase(NULL, NULL, true) { SET_WNDPROC("genkey") setIcon(Pict("encrypted")); setButtonsPict(this); setCaption(caption()); cmbMail->setEditable(true); m_exec = NULL; m_cfg = cfg; connect(edtName, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&))); connect(cmbMail->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&))); Contact *owner = getContacts()->owner(); if (owner){ QString name; name = owner->getFirstName(); QString firstName = getToken(name, '/'); name = owner->getLastName(); QString lastName = getToken(name, '/'); if (firstName.isEmpty() || lastName.isEmpty()){ name = firstName + lastName; }else{ name = firstName + " " + lastName; } edtName->setText(name); QString mails = owner->getEMails(); while (!mails.isEmpty()){ QString item = getToken(mails, ';'); QString mail = getToken(item, '/'); cmbMail->insertItem(mail); } } }
void ICQSecure::fillListView(ListView *lst, SIM::Data ICQUserData::* field) { lst->clear(); Contact *contact; ContactList::ContactIterator it; while ((contact = ++it) != NULL){ ICQUserData *data; ClientDataIterator it(contact->clientData, m_client); while ((data = m_client->toICQUserData(++it)) != NULL){ if ((data->*field).toULong()){ QString firstName = contact->getFirstName(); QString lastName = contact->getLastName(); firstName = getToken(firstName, '/'); lastName = getToken(lastName, '/'); if (!lastName.isEmpty()){ if (!firstName.isEmpty()) firstName += ' '; firstName += lastName; } QString mails; QString emails = contact->getEMails(); while (emails.length()){ QString mailItem = getToken(emails, ';', false); mailItem = getToken(mailItem, '/'); if (!mails.isEmpty()) mails += ", "; mails += mailItem; } QListViewItem *item = new QListViewItem(lst); item->setText(0,QString::number(data->Uin.toULong())); item->setText(1,contact->getName()); item->setText(2,firstName); item->setText(3,mails); item->setText(4,QString::number(contact->id())); unsigned long status = STATUS_UNKNOWN; unsigned style = 0; QString statusIcon; ((Client*)m_client)->contactInfo(data, status, style, statusIcon); item->setPixmap(0, Pict(statusIcon)); } } } }
void ICQSecure::fillListView(ListView *lst, unsigned offs) { lst->clear(); Contact *contact; ContactList::ContactIterator it; while ((contact = ++it) != NULL){ ICQUserData *data; ClientDataIterator it(contact->clientData, m_client); while ((data = (ICQUserData*)(++it)) != NULL){ if (*((unsigned short*)(((char*)data) + offs))){ QString firstName = contact->getFirstName(); QString lastName = contact->getLastName(); firstName = getToken(firstName, '/'); lastName = getToken(lastName, '/'); if (!lastName.isEmpty()){ if (!firstName.isEmpty()) firstName += " "; firstName += lastName; } QString mails; QString emails = contact->getEMails(); while (emails.length()){ QString mailItem = getToken(emails, ';', false); mailItem = getToken(mailItem, '/'); if (!mails.isEmpty()) mails += ", "; mails += mailItem; } QListViewItem *item = new ListViewItem(lst, QString::number(data->Uin), contact->getName(), firstName, mails); unsigned long status = STATUS_UNKNOWN; unsigned style = 0; const char *statusIcon; ((Client*)m_client)->contactInfo(data, status, style, statusIcon); item->setPixmap(0, Pict(statusIcon)); } } } }
void *ActionPlugin::processEvent(Event *e) { if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->id == CmdAction) && (cmd->menu_id == MenuContact)){ Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact == NULL) return NULL; ActionUserData *data = (ActionUserData*)(contact->getUserData(action_data_id)); if ((data == NULL) || (data->NMenu.value == 0)) return NULL; CommandDef *cmds = new CommandDef[data->NMenu.value + 1]; memset(cmds, 0, sizeof(CommandDef) * (data->NMenu.value + 1)); unsigned n = 0; for (unsigned i = 0; i < data->NMenu.value; i++){ QString str = get_str(data->Menu, i + 1); QString item = getToken(str, ';'); int pos = item.find("&IP;"); if (pos >= 0){ Event e(EventGetContactIP, contact); if (e.process() == NULL) continue; } pos = item.find("&Mail;"); if (pos >= 0){ if (contact->getEMails().isEmpty()) continue; } pos = item.find("&Phone;"); if (pos >= 0){ if (contact->getPhones().isEmpty()) continue; } cmds[n].id = CmdAction + i; cmds[n].text = "_"; cmds[n].text_wrk = strdup(item.utf8()); n++; } if (n == 0){ delete[] cmds; return NULL; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; return e->param(); } return NULL; } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->menu_id == MenuContact) && (cmd->id >= CmdAction)){ unsigned n = cmd->id - CmdAction; Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact == NULL) return NULL; ActionUserData *data = (ActionUserData*)(contact->getUserData(action_data_id)); if ((data == NULL) || (n >= data->NMenu.value)) return NULL; QString str = get_str(data->Menu, n + 1); getToken(str, ';'); TemplateExpand t; t.tmpl = str; t.contact = contact; t.receiver = this; t.param = NULL; Event eTmpl(EventTemplateExpand, &t); eTmpl.process(); return e->param(); } return NULL; } if (e->type() == EventContactOnline){ Contact *contact = (Contact*)(e->param()); if (contact == NULL) return NULL; ActionUserData *data = (ActionUserData*)(contact->getUserData(action_data_id)); if ((data == NULL) || (data->OnLine.ptr == NULL)) return NULL; TemplateExpand t; t.tmpl = QString::fromUtf8(data->OnLine.ptr); t.contact = contact; t.receiver = this; t.param = NULL; Event eTmpl(EventTemplateExpand, &t); eTmpl.process(); return e->param(); } if (e->type() == EventMessageReceived){ Message *msg = (Message*)(e->param()); Contact *contact = getContacts()->contact(msg->contact()); if (contact == NULL) return NULL; ActionUserData *data = (ActionUserData*)(contact->getUserData(action_data_id)); if (data == NULL) return NULL; if (msg->type() == MessageStatus){ if (data->Status.ptr == NULL) return NULL; TemplateExpand t; t.tmpl = QString::fromUtf8(data->Status.ptr); t.contact = contact; t.receiver = this; t.param = NULL; Event eTmpl(EventTemplateExpand, &t); eTmpl.process(); return NULL; } const char *cmd = get_str(data->Message, msg->baseType()); if ((cmd == NULL) || (*cmd == 0)) return NULL; TemplateExpand t; t.tmpl = QString::fromUtf8(cmd); t.contact = contact; t.receiver = this; t.param = msg; Event eTmpl(EventTemplateExpand, &t); eTmpl.process(); return e->param(); } if (e->type() == EventTemplateExpanded){ TemplateExpand *t = (TemplateExpand*)(e->param()); Message *msg = (Message*)(t->param); if (msg){ MsgExec *exec = new MsgExec; exec->msg = msg; m_exec.push_back(exec); connect(exec, SIGNAL(ready(Exec*,int,const char*)), this, SLOT(msg_ready(Exec*,int,const char*))); QString text = msg->presentation(); exec->execute(t->tmpl.local8Bit(), unquoteText(text).local8Bit()); }else{
QString Tmpl::process(TmplExpand &t, const QString &str) { QString res; QString s = str; while (!s.isEmpty()){ res += getToken(s, '&'); if(s.isEmpty()) break; QString tag = getToken(s, ';'); if (tag.isEmpty()) { res += tag; log(L_WARN, "Found '&' without ';' while parsing %s", str.local8Bit().data()); continue; } Contact *contact; if (tag.startsWith("My")){ contact = getContacts()->owner(); tag = tag.mid(2); }else{ contact = t.tmpl.contact; } if (contact == NULL) continue; if (tag == "TimeStatus"){ QDateTime dt; dt.setTime_t(CorePlugin::m_plugin->getStatusTime()); res += dt.toString("hh:mm"); continue; } if (tag == "IntervalStatus"){ res += QString::number(time(NULL) - CorePlugin::m_plugin->getStatusTime()); continue; } if (tag == "IP"){ EventGetContactIP e(contact); struct in_addr addr; e.process(); if (e.ip()) addr.s_addr = e.ip()->ip(); else addr.s_addr = 0; res += inet_ntoa(addr); continue; } if (tag == "Mail"){ QString mails = contact->getEMails(); QString mail = getToken(mails, ';', false); res += getToken(mail, '/'); continue; } if (tag == "Phone"){ QString phones = contact->getPhones(); QString phone_item = getToken(phones, ';', false); phone_item = getToken(phone_item, '/', false); res += getToken(phone_item, ','); continue; } if (tag == "Unread"){ unsigned nUnread = 0; for (list<msg_id>::iterator it = CorePlugin::m_plugin->unread.begin(); it != CorePlugin::m_plugin->unread.end(); ++it){ if ((*it).contact == contact->id()) nUnread++; } res += QString::number(nUnread); continue; } if (getTag(tag, &(contact->data.Group), contact->dataDef(), res)) continue; clientData *data; ClientDataIterator itc(contact->clientData); while ((data = ++itc) != NULL){ if (getTag(tag, &(data->Sign), itc.client()->protocol()->userDataDef(), res)) break; } if (data) continue; UserDataDef *def; ContactList::UserDataIterator it; while ((def = ++it) != NULL){ SIM::Data *data = (SIM::Data*)contact->getUserData(def->id); if (data == NULL) continue; if (getTag(tag, data, def->def, res)){ break; } } } return res; }
void *NavigatePlugin::processEvent(Event *e) { #ifdef WIN32 if (e->type() == EventGetURL){ string *url = (string*)(e->param()); *url = getCurrentUrl(); return e->param(); } #endif if (e->type() == EventGoURL){ string url = (const char*)(e->param()); string proto; if (url.length() == 0) return NULL; int n = url.find(':'); if (n < 0){ proto = "http"; url = proto + "://" + url; }else{ proto = url.substr(0, n); if ((proto != "http") && (proto != "https") && (proto != "ftp") && (proto != "file") && (proto != "mailto")) return NULL; } #ifdef WIN32 bool bExec = false; if (getNewWindow()){ string key_name = proto; key_name += "\\Shell\\Open"; RegEntry rp(HKEY_CLASSES_ROOT, key_name.c_str()); string prg = rp.value("command"); string action = rp.value("ddeexec"); string topic = rp.value("ddeexec\\Topic"); string server = rp.value("ddeexec\\Application"); if (!action.empty()){ int pos = action.find("%1"); if (pos >= 0) action = action.substr(0, pos) + url + action.substr(pos + 2); pos = prg.find("%1"); if (pos >= 0) prg = prg.substr(0, pos) + url + prg.substr(pos + 2); if (!prg.empty()){ STARTUPINFOA si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); if (CreateProcessA(NULL, (char*)prg.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)){ WaitForInputIdle(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } } DDEbase b; DDEconversation conv(server.c_str(), topic.c_str()); if (conv.Execute(action.c_str())) bExec = true; } } if (!bExec){ if (proto == "file") url = url.substr(5); ShellExecuteA(NULL, NULL, url.c_str(), NULL, NULL, SW_SHOWNORMAL); } #else ExecParam execParam; if (proto == "mailto"){ execParam.cmd = getMailer(); url = url.substr(proto.length() + 1); }else{ execParam.cmd = getBrowser(); } execParam.arg = url.c_str(); Event eExec(EventExec, &execParam); eExec.process(); #endif return e->param(); } if (e->type() == EventEncodeText){ QString *text = (QString*)(e->param()); *text = parseUrl(*text); return e->param(); } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->id == CmdMail){ Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact == NULL) return NULL; QString mails = contact->getEMails(); if (mails.length() == 0) return NULL; int nMails = 0; while (mails.length()){ getToken(mails, ';'); nMails++; } cmd->popup_id = (nMails <= 1) ? 0 : MenuMail; return e->param(); } if (cmd->id == CmdMailList){ Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact == NULL) return NULL; QString mails = contact->getEMails(); if (mails.length() == 0) return NULL; int nMails = 0; while (mails.length()){ getToken(mails, ';'); nMails++; } CommandDef *cmds = new CommandDef[nMails + 1]; unsigned n = 0; mails = contact->getEMails(); while (mails.length()){ QString mail = getToken(mails, ';', false); mail = getToken(mail, '/'); cmds[n] = *cmd; cmds[n].id = CmdMailList + n; cmds[n].flags = COMMAND_DEFAULT; cmds[n].text_wrk = strdup(mail.utf8()); n++; } memset(&cmds[n], 0, sizeof(CommandDef)); cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; return e->param(); } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->id == CmdMail){ QString mail; Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact) mail = contact->getEMails(); mail = getToken(mail, ';', false); mail = getToken(mail, '/'); if (mail.length()){ string addr = "mailto:"; addr += mail.local8Bit(); Event eMail(EventGoURL, (void*)addr.c_str()); eMail.process(); } return e->param(); } if (cmd->menu_id == MenuMail){ unsigned n = cmd->id - CmdMailList; QString mails; Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact) mails = contact->getEMails(); while (mails.length()){ QString mail = getToken(mails, ';', false); if (n-- == 0){ mail = getToken(mail, '/'); if (mail.length()){ string addr = "mailto:"; addr += mail.local8Bit(); Event eMail(EventGoURL, (void*)addr.c_str()); eMail.process(); } break; } } return e->param(); } } return NULL; }
void MainInfo::fill() { Contact *contact = m_contact; if (contact == NULL) contact = getContacts()->owner(); QString firstName = contact->getFirstName(); firstName = getToken(firstName, '/'); edtFirstName->setText(firstName); QString lastName = contact->getLastName(); lastName = getToken(lastName, '/'); edtLastName->setText(lastName); cmbDisplay->clear(); QString name = contact->getName(); if (name.length()) cmbDisplay->insertItem(name); if (firstName.length() && lastName.length()){ cmbDisplay->insertItem(firstName + " " + lastName); cmbDisplay->insertItem(lastName + " " + firstName); } if (firstName.length()) cmbDisplay->insertItem(firstName); if (lastName.length()) cmbDisplay->insertItem(lastName); cmbDisplay->lineEdit()->setText(contact->getName()); edtNotes->setText(contact->getNotes()); QString mails = contact->getEMails(); lstMails->clear(); while (mails.length()){ QString mailItem = getToken(mails, ';', false); QString mail = getToken(mailItem, '/'); QListViewItem *item = new QListViewItem(lstMails); item->setText(MAIL_ADDRESS, mail); item->setText(MAIL_PROTO, mailItem); item->setPixmap(MAIL_ADDRESS, Pict("mail_generic")); if ((m_contact == NULL) && mailItem.isEmpty()) item->setText(MAIL_PUBLISH, i18n("Yes")); } mailSelectionChanged(); QString phones = contact->getPhones(); lstPhones->clear(); unsigned n = 1; cmbCurrent->clear(); cmbCurrent->insertItem(""); while (phones.length()){ QString number; QString type; unsigned icon = 0; QString proto; QString phone = getToken(phones, ';', false); QString phoneItem = getToken(phone, '/', false); proto = phone; number = getToken(phoneItem, ','); type = getToken(phoneItem, ','); if (!phoneItem.isEmpty()) icon = atol(getToken(phoneItem, ',').latin1()); QListViewItem *item = new QListViewItem(lstPhones); fillPhoneItem(item, number, type, icon, proto); cmbCurrent->insertItem(number); if (!phoneItem.isEmpty()){ item->setText(PHONE_ACTIVE, "1"); cmbCurrent->setCurrentItem(n); } n++; } connect(lstPhones, SIGNAL(selectionChanged()), this, SLOT(phoneSelectionChanged())); phoneSelectionChanged(); }
void *NavigatePlugin::processEvent(Event *e) { if (e->type() == EventGoURL){ string url = (const char*)(e->param()); string proto; if (url.length() == 0) return NULL; int n = url.find(':'); if (n < 0){ proto = "http"; url = proto + "://" + url; }else{ proto = url.substr(0, n); if ((proto != "http") && (proto != "https") && (proto != "ftp") && (proto != "file") && (proto != "mailto")) return NULL; } #ifdef WIN32 ShellExecuteA(NULL, NULL, url.c_str(), NULL, NULL, SW_SHOWNORMAL); #else ExecParam execParam; if (proto == "mailto"){ execParam.cmd = getMailer(); url = url.substr(proto.length() + 1); }else{ execParam.cmd = getBrowser(); } execParam.arg = url.c_str(); Event eExec(EventExec, &execParam); eExec.process(); #endif return e->param(); } if (e->type() == EventEncodeText){ QString *text = (QString*)(e->param()); *text = parseUrl(*text); return e->param(); } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->id == CmdMail){ Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact == NULL) return NULL; QString mails = contact->getEMails(); if (mails.length() == 0) return NULL; int nMails = 0; while (mails.length()){ getToken(mails, ';'); nMails++; } cmd->popup_id = (nMails <= 1) ? 0 : MenuMail; return e->param(); } if (cmd->id == CmdMailList){ Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact == NULL) return NULL; QString mails = contact->getEMails(); if (mails.length() == 0) return NULL; int nMails = 0; while (mails.length()){ getToken(mails, ';'); nMails++; } CommandDef *cmds = new CommandDef[nMails + 1]; unsigned n = 0; mails = contact->getEMails(); while (mails.length()){ QString mail = getToken(mails, ';', false); mail = getToken(mail, '/'); cmds[n] = *cmd; cmds[n].id = CmdMailList + n; cmds[n].flags = COMMAND_DEFAULT; cmds[n].text_wrk = strdup(mail.utf8()); n++; } memset(&cmds[n], 0, sizeof(CommandDef)); cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; return e->param(); } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->id == CmdMail){ QString mail; Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact) mail = contact->getEMails(); mail = getToken(mail, ';', false); mail = getToken(mail, '/'); if (mail.length()){ string addr = "mailto:"; addr += mail.local8Bit(); Event eMail(EventGoURL, (void*)addr.c_str()); eMail.process(); } return e->param(); } if (cmd->menu_id == MenuMail){ unsigned n = cmd->id - CmdMailList; QString mails; Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact) mails = contact->getEMails(); while (mails.length()){ QString mail = getToken(mails, ';', false); if (n-- == 0){ mail = getToken(mail, '/'); if (mail.length()){ string addr = "mailto:"; addr += mail.local8Bit(); Event eMail(EventGoURL, (void*)addr.c_str()); eMail.process(); } break; } } return e->param(); } } return NULL; }
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; }