void Calendar::onActiveCharacterChanged(Character *c) { if (c != NULL) { setAvatar(c->getAvatar()); } else { setAvatar(NULL); } }
void IdEditDialog::setupNewId(bool pseudo) { setWindowTitle(tr("New identity")); mIsNew = true; mGroupId.clear(); ui->lineEdit_KeyId->setText(tr("To be generated")); ui->lineEdit_Nickname->setText(""); ui->radioButton_GpgId->setEnabled(true); ui->radioButton_Pseudo->setEnabled(true); if (pseudo) { ui->radioButton_Pseudo->setChecked(true); } else { ui->radioButton_GpgId->setChecked(true); } // force - incase it wasn't triggered. idTypeToggled(true); ui->frame_Tags->setHidden(true); ui->radioButton_GpgId->setEnabled(true); ui->radioButton_Pseudo->setEnabled(true); setAvatar(QPixmap()); // force resize of dialog, to hide empty space from the hidden recogn tags area adjustSize(); }
//----------------------------------------------------------------------------------------------------------------------------- void PersonView::createUI(void) { mInfo->hp = mInfo->maxHp = mConfig->hp(); mInfo->defense = mConfig->defe(); mInfo->attack = mConfig->att(); mInfo->maxattack = mConfig->maxatt(); mInfo->attackDelay = (float)mConfig->delay() / 1000; CCArmature* armature = CCArmature::create(mConfig->name().c_str()); setAvatar(armature); //if (id == 3) //{ // CCBone* bone = armature->getBone("staff"); // CCSpriteDisplayData displayData; // displayData.setParam("Pastor-weapon-pastor_staff_1.png"); // bone->addDisplay(&displayData, 1); // bone->changeDisplayByIndex(1, true); //} if (mBloodBar == NULL) { mBloodBar = BloodBar::create(); CCRect trect = CCRectApplyAffineTransform(armature->boundingBox(), armature->nodeToParentTransform()); // 获取模型的大小 mBloodBar->setPositionY(trect.getMaxY()); addChild(mBloodBar, 1); } }
rosterItem::rosterItem(const QString& bareJid) { setData(bareJid, rosterItem::BareJid); setData("Offline", rosterItem::StatusText); setAvatar(QImage(":/icons/resource/avatar.png")); setIcon(QIcon(":/icons/resource/gray.png")); }
INT_PTR GGPROTO::setmyavatar(WPARAM wParam, LPARAM lParam) { TCHAR *szFilename = (TCHAR*)lParam; if (!getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)) return -2; if (szFilename == NULL) { MessageBox(NULL, TranslateT("To remove your Gadu-Gadu avatar, you must use the gg.pl website."), m_tszUserName, MB_OK | MB_ICONINFORMATION); return -1; } int iAvType = ProtoGetAvatarFormat(szFilename); if ( iAvType == PA_FORMAT_UNKNOWN) { debugLogA("setmyavatar(): Failed to set user avatar. File %s has incompatible extension.", szFilename); return -1; } setByte(GG_KEY_AVATARTYPEPREV, getByte(GG_KEY_AVATARTYPE, -1)); setByte(GG_KEY_AVATARTYPE, (BYTE)iAvType); TCHAR szMyFilename[MAX_PATH]; getAvatarFilename(NULL, szMyFilename, _countof(szMyFilename)); if ( mir_tstrcmp(szFilename, szMyFilename) && !CopyFile(szFilename, szMyFilename, FALSE)) { debugLogA("setmyavatar(): Failed to set user avatar. File with type %d could not be created/overwritten.", iAvType); return -1; } setAvatar(szMyFilename); return 0; }
GuiAvatarButton::GuiAvatarButton(const QString path, const int Diameter, QWidget *parent) { diameter = Diameter; setAvatar(path); this->setParent(parent); }
QtRosterHeader::QtRosterHeader(SettingsProvider* settings, QWidget* parent) : QWidget(parent) { QHBoxLayout* topLayout = new QHBoxLayout(); topLayout->setSpacing(3); topLayout->setContentsMargins(4,4,4,4); setLayout(topLayout); setMinimumHeight(50); setMaximumHeight(50); avatarLabel_ = new QtClickableLabel(this); avatarLabel_->setMinimumSize(avatarSize_, avatarSize_); avatarLabel_->setMaximumSize(avatarSize_, avatarSize_); avatarLabel_->setAlignment(Qt::AlignCenter); setAvatar(":/icons/avatar.png"); avatarLabel_->setScaledContents(false); topLayout->addWidget(avatarLabel_); connect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest())); QVBoxLayout* rightLayout = new QVBoxLayout(); rightLayout->setSpacing(4); rightLayout->setContentsMargins(4,0,0,0); topLayout->addLayout(rightLayout); nameWidget_ = new QtNameWidget(settings, this); connect(nameWidget_, SIGNAL(onChangeNickRequest()), this, SIGNAL(onEditProfileRequest())); rightLayout->addWidget(nameWidget_); statusWidget_ = new QtStatusWidget(this); connect(statusWidget_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleChangeStatusRequest(StatusShow::Type, const QString&))); rightLayout->addWidget(statusWidget_); show(); }
void IdEditDialog::changeAvatar() { AvatarDialog dialog(this); dialog.setAvatar(mAvatar); if (dialog.exec() == QDialog::Accepted) { QPixmap newAvatar; dialog.getAvatar(newAvatar); setAvatar(newAvatar); } }
void lmcMainWindow::start(void) { // if no avatar is set, select a random avatar (useful when running for the first time) if(nAvatar > AVT_COUNT) { qsrand((uint)QTime::currentTime().msec()); nAvatar = qrand() % AVT_COUNT; } // This method should only be called from here, otherwise an MT_Notify message is sent // and the program will connect to the network before start() is called. setAvatar(); pTrayIcon->setVisible(showSysTray); if(pSettings->value(IDS_AUTOSHOW, IDS_AUTOSHOW_VAL).toBool()) show(); }
//! [2] void Contact::avatarUpdated(const QString& handle, const bb::platform::bbm::ImageType::Type imageType, const QByteArray& displayPicture) { Q_UNUSED(imageType); //Verify the update handle corresponds to this contact handle if (QString::compare(m_bbmspContact.handle(), handle) == 0) { // Verify that there is an image to be set. if(displayPicture.size() != 0) { setAvatar(displayPicture); } } }
void MainWindow::finished() { QJsonParseError parseError; QJsonDocument document = QJsonDocument::fromJson(reply_->readAll(), &parseError); if (parseError.error == QJsonParseError::NoError) { QList<QObject *> members; foreach (const QJsonValue& value, document.array()) { QJsonObject object = value.toObject(); auto member = new Member(this); member->setName(object[TAG_NAME].toString()); member->setAvatar(object[TAG_AVATAR].toString()); members << member; } rootContext()->setContextProperty(TAG_MODEL, QVariant::fromValue(members)); }
QtRosterHeader::QtRosterHeader(SettingsProvider* settings, StatusCache* statusCache, QWidget* parent) : QWidget(parent), statusEdit_(NULL) { QHBoxLayout* topLayout = new QHBoxLayout(); topLayout->setSpacing(3); topLayout->setContentsMargins(4,4,4,4); setLayout(topLayout); setMinimumHeight(50); setMaximumHeight(50); avatarLabel_ = new QtClickableLabel(this); avatarLabel_->setMinimumSize(avatarSize_, avatarSize_); avatarLabel_->setMaximumSize(avatarSize_, avatarSize_); avatarLabel_->setAlignment(Qt::AlignCenter); setAvatar(":/icons/avatar.png"); avatarLabel_->setScaledContents(false); topLayout->addWidget(avatarLabel_); connect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest())); QVBoxLayout* rightLayout = new QVBoxLayout(); rightLayout->setSpacing(4); rightLayout->setContentsMargins(4,0,0,0); topLayout->addLayout(rightLayout); QHBoxLayout* nameAndSecurityLayout = new QHBoxLayout(); nameAndSecurityLayout->setContentsMargins(4,0,0,0); nameWidget_ = new QtNameWidget(settings, this); connect(nameWidget_, SIGNAL(onChangeNickRequest()), this, SIGNAL(onEditProfileRequest())); nameAndSecurityLayout->addWidget(nameWidget_); securityInfoButton_ = new QToolButton(this); securityInfoButton_->setStyleSheet("QToolButton { border: none; } QToolButton:hover { border: 1px solid #bebebe; } QToolButton:pressed { border: 1px solid #757575; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #777777, stop: 1 #d4d4d4);}"); //securityInfoButton_->setAutoRaise(true); securityInfoButton_->setIcon(QIcon(":/icons/lock.png")); securityInfoButton_->setToolTip(tr("Connection is secured")); connect(securityInfoButton_, SIGNAL(clicked()), this, SIGNAL(onShowCertificateInfo())); nameAndSecurityLayout->addWidget(securityInfoButton_); rightLayout->addLayout(nameAndSecurityLayout); statusWidget_ = new QtStatusWidget(statusCache, this); connect(statusWidget_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleChangeStatusRequest(StatusShow::Type, const QString&))); rightLayout->addWidget(statusWidget_); show(); }
void Contact::setAvatar(const QUrl &avatarPath) { qDebug() << avatarPath; // TODO: when we write a GalleryModel, we'll want some way to select part of // an image to use as an avatar, but this lazy hack will do for now QImage img(avatarPath.toLocalFile()); // scale up or down img = img.scaled(QSize(128, 128), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); if (img.size().height() > 128 || img.size().width() > 128) { // scale down, and crop it to a square // TODO: would be nice to pick a region of the image to scale+crop. img = img.copy(QRect(0, 0, 128, 128)); } setAvatar(img); }
void QTlenRosterManager::presenceFrom(QString jid, QTlenPresence type, QString description, QString av_type, QString digest) { if (getIndexOf(jid) != -1) { int index = getIndexOf(jid); rosterItems[index].presence = type; rosterItems[index].desc = description; rosterItems[index].avatar_type = av_type; //TODO: fetch avatars if (av_type != "-1") { QString nick = jid; nick.chop(8); QTlenAvatarsFetcher *fetcher = new QTlenAvatarsFetcher(); //token nick digest connect(fetcher, SIGNAL(gotAvatar(QString,QPixmap)), this, SLOT(setAvatar(QString, QPixmap))); rosterItems[index].avatar = fetcher->getAvatar(av_manager, mailInfo, token, nick, digest); } sysIcon->showMessage(QString::fromUtf8("Zmiana statusu"), rosterItems[index].name + " ma teraz status " + QSStatus(type)); } else { RosterItem i; i.jid = jid; i.name = jid; if (description.isEmpty()) i.desc = ""; else i.desc = description; i.subscription = "both"; i.presence = type; i.group = "Tlen"; rosterItems.append(i); } showRoster(); };
void IdEditDialog::setupNewId(bool pseudo,bool enable_anon) { setWindowTitle(tr("New identity")); if(pseudo && !enable_anon) { std::cerr << "IdEditDialog::setupNewId: Error. Cannot init with pseudo-anonymous id when anon ids are disabled." << std::endl; pseudo = false ; } mIsNew = true; mGroupId.clear(); ui->lineEdit_KeyId->setText(tr("To be generated")); ui->lineEdit_Nickname->setText(""); ui->radioButton_GpgId->setEnabled(true); ui->radioButton_Pseudo->setEnabled(true); if (pseudo) { ui->radioButton_Pseudo->setChecked(true); } else { ui->radioButton_GpgId->setChecked(true); } // force - incase it wasn't triggered. idTypeToggled(true); ui->frame_Tags->setHidden(true); ui->radioButton_GpgId->setEnabled(true); if(enable_anon) ui->radioButton_Pseudo->setEnabled(true); else ui->radioButton_Pseudo->setEnabled(false); setAvatar(QPixmap()); // force resize of dialog, to hide empty space from the hidden recogn tags area adjustSize(); }
/** * @brief Initializes the core, must be called before anything else */ void Core::start() { bool isNewProfile = profile.isNewProfile(); if (isNewProfile) { qDebug() << "Creating a new profile"; makeTox(QByteArray()); setStatusMessage(tr("Toxing on qTox")); setUsername(profile.getName()); } else { qDebug() << "Loading user profile"; QByteArray savedata = profile.loadToxSave(); if (savedata.isEmpty()) { emit failedToStart(); return; } makeTox(savedata); } qsrand(time(nullptr)); if (!tox) { ready = true; GUI::setEnabled(true); return; } // set GUI with user and statusmsg QString name = getUsername(); if (!name.isEmpty()) emit usernameSet(name); QString msg = getStatusMessage(); if (!msg.isEmpty()) emit statusMessageSet(msg); QString id = getSelfId().toString(); if (!id.isEmpty()) emit idSet(id); // TODO: This is a backwards compatibility check, // once most people have been upgraded away from the old HistoryKeeper, remove this if (Nexus::getProfile()->isEncrypted()) checkEncryptedHistory(); loadFriends(); tox_callback_friend_request(tox, onFriendRequest, this); tox_callback_friend_message(tox, onFriendMessage, this); tox_callback_friend_name(tox, onFriendNameChange, this); tox_callback_friend_typing(tox, onFriendTypingChange, this); tox_callback_friend_status_message(tox, onStatusMessageChanged, this); tox_callback_friend_status(tox, onUserStatusChanged, this); tox_callback_friend_connection_status(tox, onConnectionStatusChanged, this); tox_callback_friend_read_receipt(tox, onReadReceiptCallback, this); tox_callback_group_invite(tox, onGroupInvite, this); tox_callback_group_message(tox, onGroupMessage, this); tox_callback_group_namelist_change(tox, onGroupNamelistChange, this); tox_callback_group_title(tox, onGroupTitleChange, this); tox_callback_group_action(tox, onGroupAction, this); tox_callback_file_chunk_request(tox, CoreFile::onFileDataCallback, this); tox_callback_file_recv(tox, CoreFile::onFileReceiveCallback, this); tox_callback_file_recv_chunk(tox, CoreFile::onFileRecvChunkCallback, this); tox_callback_file_recv_control(tox, CoreFile::onFileControlCallback, this); QPixmap pic = profile.loadAvatar(); if (!pic.isNull() && !pic.size().isEmpty()) { QByteArray data; QBuffer buffer(&data); buffer.open(QIODevice::WriteOnly); pic.save(&buffer, "PNG"); buffer.close(); setAvatar(data); } else { qDebug() << "Self avatar not found, will broadcast empty avatar to friends"; setAvatar({}); } ready = true; // If we created a new profile earlier, // now that we're ready save it and ONLY THEN broadcast the new ID. // This is useful for e.g. the profileForm that searches for saves. if (isNewProfile) { profile.saveToxSave(); emit idSet(getSelfId().toString()); } if (isReady()) GUI::setEnabled(true); process(); // starts its own timer av->start(); }
void jConference::handlePresence (const Presence &presence) { if(presence.subtype()==Presence::Error) return; const MUCRoom::MUCUser* mu = presence.findExtension<MUCRoom::MUCUser>(ExtMUCUser); if(!mu) return; QString conference = utils::fromStd(presence.from().bare()); Room *room = m_rooms.value(conference); if(!room) return; QString nick = utils::fromStd(presence.from().resource()); QHash<QString,MucContact> &contacts = room->contacts_list; int flags = mu->flags(); bool send_role=false; if( flags & UserNickChanged && mu->newNick() ) { // changed nick to new_nick QString new_nick = utils::fromStd(*mu->newNick()); if(!contacts.contains(nick)) return; MucContact contact = contacts[nick]; jBuddy::ResourceInfo *info = &contact.m_info; info->m_name = new_nick; contacts.remove(nick); contacts.insert(new_nick, contact); emit addSystemMessageToConference("Jabber",conference,m_account_name,tr("%1 is now known as %2").arg(nick).arg(new_nick),QDateTime(),false); emit renameConferenceItem("Jabber", conference, m_account_name, nick, new_nick); return; } bool if_join=false; if(presence.presence()==Presence::Unavailable && contacts.contains(nick)) { QString reason = ""; if(mu->reason()) reason = utils::fromStd(*mu->reason()); if (utils::fromStd(room->entity->nick()) == nick) { QString msgtxt; if(flags & UserKicked){ msgtxt += tr("You have been kicked from")+" "+conference+".\n"; if (!reason.isEmpty()){ msgtxt += tr("with reason:")+" "+reason+".\n"; } else { msgtxt += tr("without reason")+".\n"; } QMessageBox::warning(0, tr("You have been kicked"), msgtxt, QMessageBox::Ok); // //TODO: autorejoin? // msgtxt += tr("Do you want to rejoin?"); // int ret = QMessageBox::warning(0, tr("You have been kicked"), msgtxt, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); // if(ret==QMessageBox::Yes) { // JID jid(utils::toStd(conference)); // m_room_list[conference]->leave(""); // m_room_list[conference]->join(m_presence->presence(), m_presence->status()); //// createConferenceRoom(utils::fromStd(jid.server()), utils::fromStd(jid.username()), nick, "" ); // return; // } } else if(flags & UserBanned){ msgtxt += tr("You have been banned from")+" "+conference+".\n"; if (!reason.isEmpty()){ msgtxt += tr("with reason:")+" "+reason+".\n"; } else { msgtxt += tr("without reason")+".\n"; } QMessageBox::warning(0, tr("You have been banned"), msgtxt, QMessageBox::Ok); } } //offline contacts.remove(nick); emit removeConferenceItem("Jabber", conference, m_account_name, nick); QString text; if(flags & UserKicked) text = tr("%1 has been kicked").arg(nick); else if(flags & UserBanned) text = tr("%1 has been banned").arg(nick); else text = tr("%1 has left the room").arg(nick); if (!reason.isEmpty()) text += " ("+reason+")"; emit addSystemMessageToConference("Jabber",conference,m_account_name,text,QDateTime(),false); return; } else if(presence.presence()==Presence::Unavailable) return; else { QString status; int mass; switch(presence.presence()) { case Presence::Chat: status="ffc"; mass=1; break; case Presence::Away: status="away"; mass=2; break; case Presence::DND: status="dnd"; mass=3; break; case Presence::XA: status="na"; mass=4; break; case Presence::Error: return; case Presence::Available: default: status="online"; mass=0; break; } if(!contacts.contains(nick) || contacts[nick].m_info.m_name.isNull() || contacts[nick].m_info.m_name.isEmpty()) { //online if(!contacts.contains(nick)) { MucContact contact; jBuddy::ResourceInfo info; info.m_name = nick; info.m_chat_state = ChatStateActive; contact.m_info = info; contact.m_affiliation = AffiliationNone; contact.m_role = RoleInvalid ; contacts.insert(nick,contact); emit addConferenceItem("Jabber", conference, m_account_name, nick); } MucContact *contact = &contacts[nick]; jBuddy::ResourceInfo *info = &contact->m_info; info->m_name = nick; info->m_presence = presence.presence(); if(presence.presence() == Presence::Invalid) info->m_presence = Presence::Available; info->m_priority = 0; if_join=true; emit setConferenceItemRole("Jabber", conference, m_account_name, nick, status, mass); send_role=true; // JID jid(room->name()+"@"+room->service()+"/"+participant.nick->resource()); // jClientIdentification::instance().setClient(&(contacts[nick]),jid,m_client_base,this); } else contacts[nick].m_info.m_presence = presence.presence(); if(contacts[nick].m_real_jid.isEmpty() && mu->jid()) contacts[nick].m_real_jid = utils::fromStd(*mu->jid()); //changed status emit setConferenceItemStatus("Jabber", conference, m_account_name, nick, status, mass); } if(contacts.contains(nick)) { MucContact *contact = &contacts[nick]; QString message; if(!if_join && mu->role()==contact->m_role && mu->affiliation()==contact->m_affiliation) return; if(if_join && contact->m_real_jid.isEmpty()) { if(mu->role()!=contact->m_role&&mu->affiliation()!=contact->m_affiliation) message = tr("%3 has joined the room as %1 and %2"); else if(mu->role()!=contact->m_role||mu->affiliation()!=contact->m_affiliation) message = tr("%2 has joined the room as %1"); else message = tr("%2 has joined the room"); } else if(if_join) { if(mu->role()!=contact->m_role&&mu->affiliation()!=contact->m_affiliation) message = tr("%4 (%3) has joined the room as %1 and %2"); else if(mu->role()!=contact->m_role||mu->affiliation()!=contact->m_affiliation) message = tr("%3 (%2) has joined the room as %1"); else message = tr("%2 (%1) has joined the room"); } else if(contact->m_real_jid.isEmpty()) { if(mu->role()!=contact->m_role&&mu->affiliation()!=contact->m_affiliation) message = tr("%3 now is %1 and %2"); else if(mu->role()!=contact->m_role||mu->affiliation()!=contact->m_affiliation) message = tr("%2 now is %1"); } else { if(mu->role()!=contact->m_role&&mu->affiliation()!=contact->m_affiliation) message = tr("%4 (%3) now is %1 and %2"); else if(mu->role()!=contact->m_role||mu->affiliation()!=contact->m_affiliation) message = tr("%3 (%2) now is %1"); } if(mu->role()!=contact->m_role) { int mass; QString role; switch(mu->role()) { case RoleModerator: role=tr("moderator"); mass=1; break; case RoleParticipant: role=tr("participant"); mass=2; break; default: case RoleVisitor: role=tr("visitor"); mass=3; break; } contact->m_role = mu->role(); contact->m_role_string = role; message = message.arg(role); contact->m_info.m_priority = mass; emit setConferenceItemRole("Jabber", conference, m_account_name, nick, role, mass); } if(mu->affiliation()!=contact->m_affiliation) { QString affiliation; switch(mu->affiliation()) { case AffiliationOutcast: affiliation=tr("banned"); break; case AffiliationMember: affiliation=tr("member"); break; case AffiliationOwner: affiliation=tr("owner"); break; case AffiliationAdmin: affiliation=tr("administrator"); break; default: affiliation=tr("guest"); break; } contact->m_affiliation = mu->affiliation(); contact->m_affiliation_string = mu->affiliation()==AffiliationNone?"":affiliation; message = message.arg(affiliation); } if(!contact->m_real_jid.isEmpty()) message = message.arg(contact->m_real_jid); message = message.arg(nick); emit addSystemMessageToConference("Jabber",conference,m_account_name,message,QDateTime(),false); } jBuddy::ResourceInfo *info = &contacts[nick].m_info; info->m_status_message = utils::fromStd(presence.status()); info->m_status_message.replace("\n","<br/>"); if(info->m_client_name.isEmpty()||info->m_client_name.isNull()) { const Capabilities *caps = presence.capabilities(); if(caps) { info->m_caps_ver = utils::fromStd(caps->ver()); info->m_caps_node = utils::fromStd(caps->node()); } else { info->m_caps_ver = ""; info->m_caps_node = ""; } jClientIdentification::instance().setClient(info,presence.from(),m_client_base,this); emit conferenceClientVersion("Jabber",conference,m_account_name,nick, info->m_client_name); } const VCardUpdate *vcard_update = presence.findExtension<VCardUpdate>(ExtVCardUpdate); if(vcard_update) { QString hash = utils::fromStd(vcard_update->hash()); if(!hash.isEmpty()) { if(QFile(m_jabber_account->getPathToAvatars()+"/"+hash).exists()) { setAvatar(conference,nick,m_jabber_account->getPathToAvatars()+"/"+hash); } else { m_real_parent->fetchVCard(conference+"/"+nick,true); } } } const XStatusExtension *xstatus = presence.findExtension<XStatusExtension>(SExtXStatus); if(xstatus) { if(xstatus->status_id()<0) info->m_x_status=""; else info->m_x_status = QString("icq_xstatus%1").arg(xstatus->status_id()); emit setConferenceItemIcon("Jabber",conference,m_account_name,nick, info->m_x_status, 5); } }
void Core::start() { // IPv6 needed for LAN discovery, but can crash some weird routers. On by default, can be disabled in options. bool enableIPv6 = Settings::getInstance().getEnableIPv6(); bool forceTCP = Settings::getInstance().getForceTCP(); bool useProxy = Settings::getInstance().getUseProxy(); if (enableIPv6) qDebug() << "Core starting with IPv6 enabled"; else qWarning() << "Core starting with IPv6 disabled. LAN discovery may not work properly."; Tox_Options toxOptions; toxOptions.ipv6enabled = enableIPv6; toxOptions.udp_disabled = forceTCP; // No proxy by default toxOptions.proxy_enabled = false; toxOptions.proxy_address[0] = 0; toxOptions.proxy_port = 0; if (useProxy) { QString proxyAddr = Settings::getInstance().getProxyAddr(); int proxyPort = Settings::getInstance().getProxyPort(); if (proxyAddr.length() > 255) { qWarning() << "Core: proxy address" << proxyAddr << "is too long"; } else if (proxyAddr != "" && proxyPort > 0) { qDebug() << "Core: using proxy" << proxyAddr << ":" << proxyPort; toxOptions.proxy_enabled = true; uint16_t sz = CString::fromString(proxyAddr, (unsigned char*)toxOptions.proxy_address); toxOptions.proxy_address[sz] = 0; toxOptions.proxy_port = proxyPort; } } tox = tox_new(&toxOptions); if (tox == nullptr) { if (enableIPv6) // Fallback to IPv4 { toxOptions.ipv6enabled = false; tox = tox_new(&toxOptions); if (tox == nullptr) { if (toxOptions.proxy_enabled) { //QMessageBox::critical(Widget::getInstance(), tr("Proxy failure", "popup title"), //tr("toxcore failed to start with your proxy settings. qTox cannot run; please modify your " //"settings and restart.", "popup text")); qCritical() << "Core: bad proxy! no toxcore!"; emit badProxy(); } else { qCritical() << "Tox core failed to start"; emit failedToStart(); } return; } else qWarning() << "Core failed to start with IPv6, falling back to IPv4. LAN discovery may not work properly."; } else if (toxOptions.proxy_enabled) { emit badProxy(); return; } else { qCritical() << "Tox core failed to start"; emit failedToStart(); return; } } toxav = toxav_new(tox, TOXAV_MAX_CALLS); if (toxav == nullptr) { qCritical() << "Toxav core failed to start"; emit failedToStart(); return; } qsrand(time(nullptr)); if (!loadConfiguration()) { emit failedToStart(); tox_kill(tox); tox = nullptr; return; } tox_callback_friend_request(tox, onFriendRequest, this); tox_callback_friend_message(tox, onFriendMessage, this); tox_callback_friend_action(tox, onAction, this); tox_callback_name_change(tox, onFriendNameChange, this); tox_callback_typing_change(tox, onFriendTypingChange, this); tox_callback_status_message(tox, onStatusMessageChanged, this); tox_callback_user_status(tox, onUserStatusChanged, this); tox_callback_connection_status(tox, onConnectionStatusChanged, this); tox_callback_group_invite(tox, onGroupInvite, this); tox_callback_group_message(tox, onGroupMessage, this); tox_callback_group_namelist_change(tox, onGroupNamelistChange, this); tox_callback_file_send_request(tox, onFileSendRequestCallback, this); tox_callback_file_control(tox, onFileControlCallback, this); tox_callback_file_data(tox, onFileDataCallback, this); tox_callback_avatar_info(tox, onAvatarInfoCallback, this); tox_callback_avatar_data(tox, onAvatarDataCallback, this); toxav_register_callstate_callback(toxav, onAvInvite, av_OnInvite, this); toxav_register_callstate_callback(toxav, onAvStart, av_OnStart, this); toxav_register_callstate_callback(toxav, onAvCancel, av_OnCancel, this); toxav_register_callstate_callback(toxav, onAvReject, av_OnReject, this); toxav_register_callstate_callback(toxav, onAvEnd, av_OnEnd, this); toxav_register_callstate_callback(toxav, onAvRinging, av_OnRinging, this); toxav_register_callstate_callback(toxav, onAvStarting, av_OnStarting, this); toxav_register_callstate_callback(toxav, onAvEnding, av_OnEnding, this); toxav_register_callstate_callback(toxav, onAvMediaChange, av_OnMediaChange, this); toxav_register_callstate_callback(toxav, onAvRequestTimeout, av_OnRequestTimeout, this); toxav_register_callstate_callback(toxav, onAvPeerTimeout, av_OnPeerTimeout, this); toxav_register_audio_recv_callback(toxav, playCallAudio, this); toxav_register_video_recv_callback(toxav, playCallVideo, this); uint8_t friendAddress[TOX_FRIEND_ADDRESS_SIZE]; tox_get_address(tox, friendAddress); emit friendAddressGenerated(CFriendAddress::toString(friendAddress)); QPixmap pic = Settings::getInstance().getSavedAvatar(getSelfId().toString()); if (!pic.isNull() && !pic.size().isEmpty()) { QByteArray data; QBuffer buffer(&data); buffer.open(QIODevice::WriteOnly); pic.save(&buffer, "PNG"); buffer.close(); setAvatar(TOX_AVATAR_FORMAT_PNG, data); } else qDebug() << "Core: Error loading self avatar"; process(); // starts its own timer }
/** * @brief Initializes the core, must be called before anything else */ void Core::start(const QByteArray& savedata) { bool isNewProfile = profile.isNewProfile(); if (isNewProfile) { qDebug() << "Creating a new profile"; makeTox(QByteArray()); makeAv(); setStatusMessage(tr("Toxing on qTox")); setUsername(profile.getName()); } else { qDebug() << "Loading user profile"; if (savedata.isEmpty()) { emit failedToStart(); return; } makeTox(savedata); makeAv(); } qsrand(time(nullptr)); if (!tox) { ready = true; GUI::setEnabled(true); return; } // set GUI with user and statusmsg QString name = getUsername(); if (!name.isEmpty()) { emit usernameSet(name); } QString msg = getStatusMessage(); if (!msg.isEmpty()) { emit statusMessageSet(msg); } ToxId id = getSelfId(); // TODO: probably useless check, comes basically directly from toxcore if (id.isValid()) { emit idSet(id); } loadFriends(); tox_callback_friend_request(tox, onFriendRequest); tox_callback_friend_message(tox, onFriendMessage); tox_callback_friend_name(tox, onFriendNameChange); tox_callback_friend_typing(tox, onFriendTypingChange); tox_callback_friend_status_message(tox, onStatusMessageChanged); tox_callback_friend_status(tox, onUserStatusChanged); tox_callback_friend_connection_status(tox, onConnectionStatusChanged); tox_callback_friend_read_receipt(tox, onReadReceiptCallback); tox_callback_conference_invite(tox, onGroupInvite); tox_callback_conference_message(tox, onGroupMessage); tox_callback_conference_namelist_change(tox, onGroupNamelistChange); tox_callback_conference_title(tox, onGroupTitleChange); tox_callback_file_chunk_request(tox, CoreFile::onFileDataCallback); tox_callback_file_recv(tox, CoreFile::onFileReceiveCallback); tox_callback_file_recv_chunk(tox, CoreFile::onFileRecvChunkCallback); tox_callback_file_recv_control(tox, CoreFile::onFileControlCallback); QByteArray data = profile.loadAvatarData(getSelfPublicKey().toString()); if (data.isEmpty()) { qDebug() << "Self avatar not found, will broadcast empty avatar to friends"; } setAvatar(data); ready = true; if (isNewProfile) { profile.saveToxSave(); } if (isReady()) { GUI::setEnabled(true); } process(); // starts its own timer av->start(); }
Private(ContactListAccountMenu* menu, ContactListAccountGroup* _account) : QObject(0) , account(_account) , menu_(menu) { connect(menu, SIGNAL(aboutToShow()), SLOT(updateActions())); connect(account->account(), SIGNAL(updatedActivity()), SLOT(updateActions())); connect(account->account(), SIGNAL(updatedAccount()), SLOT(updateActions())); statusMenu_ = new StatusMenu(0); statusMenu_->setTitle(tr("&Status")); connect(statusMenu_, SIGNAL(statusChanged(XMPP::Status::Type)), SLOT(statusChanged(XMPP::Status::Type))); moodAction_ = new QAction(tr("Mood"), this); connect(moodAction_, SIGNAL(triggered()), SLOT(setMood())); setAvatarAction_ = new QAction(tr("Set Avatar"), this); connect(setAvatarAction_, SIGNAL(triggered()), SLOT(setAvatar())); unsetAvatarAction_ = new QAction(tr("Unset Avatar"), this); connect(unsetAvatarAction_, SIGNAL(triggered()), SLOT(unsetAvatar())); bookmarksManageAction_ = new QAction(tr("Manage..."), this); connect(bookmarksManageAction_, SIGNAL(triggered()), SLOT(bookmarksManage())); addContactAction_ = new IconAction(tr("&Add a Contact"), this, "psi/addContact"); connect(addContactAction_, SIGNAL(triggered()), SLOT(addContact())); serviceDiscoveryAction_ = new IconAction(tr("Service &Discovery"), this, "psi/disco"); connect(serviceDiscoveryAction_, SIGNAL(triggered()), SLOT(serviceDiscovery())); newMessageAction_ = new IconAction(tr("New &Blank Message"), this, "psi/sendMessage"); connect(newMessageAction_, SIGNAL(triggered()), SLOT(newMessage())); xmlConsoleAction_ = new IconAction(tr("&XML Console"), this, "psi/xml"); connect(xmlConsoleAction_, SIGNAL(triggered()), SLOT(xmlConsole())); modifyAccountAction_ = new IconAction(tr("&Modify Account..."), this, "psi/account"); connect(modifyAccountAction_, SIGNAL(triggered()), SLOT(modifyAccount())); adminOnlineUsersAction_ = new IconAction(tr("Online Users"), this, "psi/disco"); connect(adminOnlineUsersAction_, SIGNAL(triggered()), SLOT(adminOnlineUsers())); adminSendServerMessageAction_ = new IconAction(tr("Send Server Message"), this, "psi/sendMessage"); connect(adminSendServerMessageAction_, SIGNAL(triggered()), SLOT(adminSendServerMessage())); adminSetMotdAction_ = new QAction(tr("Set MOTD"), this); connect(adminSetMotdAction_, SIGNAL(triggered()), SLOT(adminSetMotd())); adminUpdateMotdAction_ = new QAction(tr("Update MOTD"), this); connect(adminUpdateMotdAction_, SIGNAL(triggered()), SLOT(adminUpdateMotd())); adminDeleteMotdAction_ = new IconAction(tr("Delete MOTD"), this, "psi/remove"); connect(adminDeleteMotdAction_, SIGNAL(triggered()), SLOT(adminDeleteMotd())); menu->addMenu(statusMenu_); menu->addAction(moodAction_); avatarMenu_ = menu->addMenu(tr("Avatar")); avatarMenu_->addAction(setAvatarAction_); avatarMenu_->addAction(unsetAvatarAction_); bookmarksMenu_ = menu->addMenu(tr("Bookmarks")); bookmarksMenu_->addAction(bookmarksManageAction_); menu->addSeparator(); menu->addAction(addContactAction_); menu->addAction(serviceDiscoveryAction_); menu->addAction(newMessageAction_); menu->addSeparator(); menu->addAction(xmlConsoleAction_); menu->addSeparator(); menu->addAction(modifyAccountAction_); adminMenu_ = menu->addMenu("&Admin"); adminMenu_->addAction(adminOnlineUsersAction_); adminMenu_->addAction(adminSendServerMessageAction_); adminMenu_->addAction(adminSetMotdAction_); adminMenu_->addAction(adminUpdateMotdAction_); adminMenu_->addAction(adminDeleteMotdAction_); updateActions(); }
void IdEditDialog::loadExistingId(uint32_t token) { mStateHelper->setLoading(IDEDITDIALOG_LOADID, false); /* get details from libretroshare */ std::vector<RsGxsIdGroup> datavector; if (!rsIdentity->getGroupData(token, datavector)) { ui->lineEdit_KeyId->setText(tr("Error getting key!")); return; } if (datavector.size() != 1) { std::cerr << "IdDialog::insertIdDetails() Invalid datavector size"; std::cerr << std::endl; ui->lineEdit_KeyId->setText(tr("Error KeyID invalid")); ui->lineEdit_Nickname->setText(""); ui->lineEdit_GpgHash->setText(tr("N/A")); ui->lineEdit_GpgId->setText(tr("N/A")); ui->lineEdit_GpgName->setText(tr("N/A")); return; } mEditGroup = datavector[0]; mGroupId = mEditGroup.mMeta.mGroupId; QPixmap avatar; if (mEditGroup.mImage.mSize > 0) { avatar.loadFromData(mEditGroup.mImage.mData, mEditGroup.mImage.mSize, "PNG"); } setAvatar(avatar); bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID); if (realid) { ui->radioButton_GpgId->setChecked(true); } else { ui->radioButton_Pseudo->setChecked(true); } // these are not editable for existing Id. ui->radioButton_GpgId->setEnabled(false); ui->radioButton_Pseudo->setEnabled(false); // DOES THIS TRIGGER ALREADY??? // force - incase it wasn't triggered. idTypeToggled(true); ui->lineEdit_Nickname->setText(QString::fromUtf8(mEditGroup.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE)); ui->lineEdit_KeyId->setText(QString::fromStdString(mEditGroup.mMeta.mGroupId.toStdString())); if (realid) { ui->lineEdit_GpgHash->setText(QString::fromStdString(mEditGroup.mPgpIdHash.toStdString())); if (mEditGroup.mPgpKnown) { RsPeerDetails details; rsPeers->getGPGDetails(mEditGroup.mPgpId, details); ui->lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str())); ui->lineEdit_GpgId->setText(QString::fromStdString(mEditGroup.mPgpId.toStdString())); } else { ui->lineEdit_GpgId->setText(tr("Unknown GpgId")); ui->lineEdit_GpgName->setText(tr("Unknown real name")); } } else { ui->lineEdit_GpgHash->setText(tr("N/A")); ui->lineEdit_GpgId->setText(tr("N/A")); ui->lineEdit_GpgName->setText(tr("N/A")); } // RecognTags. ui->frame_Tags->setHidden(false); loadRecognTags(); }
User::User() { setAvatar(QIcon("/Users/Blecam/Downloads/user_icon.png")); }
void Core::start() { qDebug() << "Core: Starting up"; QByteArray savedata = loadToxSave(loadPath); make_tox(savedata); // Do we need to create a new save & profile? if (savedata.isNull()) { qDebug() << "Save file not found, creating a new profile"; Settings::getInstance().load(); setStatusMessage(tr("Toxing on qTox")); setUsername(tr("qTox User")); } qsrand(time(nullptr)); // set GUI with user and statusmsg QString name = getUsername(); if (!name.isEmpty()) emit usernameSet(name); QString msg = getStatusMessage(); if (!msg.isEmpty()) emit statusMessageSet(msg); QString id = getSelfId().toString(); if (!id.isEmpty()) emit idSet(id); // tox core is already decrypted if (Settings::getInstance().getEnableLogging() && Settings::getInstance().getEncryptLogs()) checkEncryptedHistory(); loadFriends(); tox_callback_friend_request(tox, onFriendRequest, this); tox_callback_friend_message(tox, onFriendMessage, this); tox_callback_friend_name(tox, onFriendNameChange, this); tox_callback_friend_typing(tox, onFriendTypingChange, this); tox_callback_friend_status_message(tox, onStatusMessageChanged, this); tox_callback_friend_status(tox, onUserStatusChanged, this); tox_callback_friend_connection_status(tox, onConnectionStatusChanged, this); tox_callback_friend_read_receipt(tox, onReadReceiptCallback, this); tox_callback_group_invite(tox, onGroupInvite, this); tox_callback_group_message(tox, onGroupMessage, this); tox_callback_group_namelist_change(tox, onGroupNamelistChange, this); tox_callback_group_title(tox, onGroupTitleChange, this); tox_callback_group_action(tox, onGroupAction, this); tox_callback_file_chunk_request(tox, CoreFile::onFileDataCallback, this); tox_callback_file_recv(tox, CoreFile::onFileReceiveCallback, this); tox_callback_file_recv_chunk(tox, CoreFile::onFileRecvChunkCallback, this); tox_callback_file_recv_control(tox, CoreFile::onFileControlCallback, this); toxav_register_callstate_callback(toxav, onAvInvite, av_OnInvite, this); toxav_register_callstate_callback(toxav, onAvStart, av_OnStart, this); toxav_register_callstate_callback(toxav, onAvCancel, av_OnCancel, this); toxav_register_callstate_callback(toxav, onAvReject, av_OnReject, this); toxav_register_callstate_callback(toxav, onAvEnd, av_OnEnd, this); toxav_register_callstate_callback(toxav, onAvRinging, av_OnRinging, this); toxav_register_callstate_callback(toxav, onAvMediaChange, av_OnPeerCSChange, this); toxav_register_callstate_callback(toxav, onAvMediaChange, av_OnSelfCSChange, this); toxav_register_callstate_callback(toxav, onAvRequestTimeout, av_OnRequestTimeout, this); toxav_register_callstate_callback(toxav, onAvPeerTimeout, av_OnPeerTimeout, this); toxav_register_audio_callback(toxav, playCallAudio, this); toxav_register_video_callback(toxav, playCallVideo, this); QPixmap pic = Settings::getInstance().getSavedAvatar(getSelfId().toString()); if (!pic.isNull() && !pic.size().isEmpty()) { QByteArray data; QBuffer buffer(&data); buffer.open(QIODevice::WriteOnly); pic.save(&buffer, "PNG"); buffer.close(); setAvatar(data); } else { qDebug() << "Core: Error loading self avatar"; } ready = true; // If we created a new profile earlier, // now that we're ready save it and ONLY THEN broadcast the new ID. // This is useful for e.g. the profileForm that searches for saves. if (savedata.isNull()) { saveConfiguration(); emit idSet(getSelfId().toString()); } if (isReady()) GUI::setEnabled(true); process(); // starts its own timer }