// Set the port on the server to which we connect. void MotionStar::setServerPort(const unsigned short port) { // If the device active, we cannot change the server port. if ( isActive() ) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_WARNING_LVL) << "gadget::MotionStar: Cannot change server port while active\n" << vprDEBUG_FLUSH; } else { mMotionStar.setServerPort(port); switch (port) { case 5000: setProtocol(BIRDNET::UDP); break; case 6000: setProtocol(BIRDNET::TCP); break; default: vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CONFIG_LVL) << "MotionStar: Unexpected port number " << port << " given!\n" << " Defaulting to TCP port.\n" << vprDEBUG_FLUSH; mMotionStar.setProtocol(BIRDNET::TCP); break; } } }
void UrlParse::setString(const char *urlstring) { protocol = hostname = path = resource = NULL; port = 0; // parse etc String cp(urlstring); char *colon = STRCHR(cp, ':'); if (colon == NULL || colon > cp.v()+4) { // new default_protocol method setProtocol(default_protocol); } else { String p = cp, tmp(colon+1); p.changeChar(':', '\0'); setProtocol(p); cp = tmp; } // eat slashes while (cp.v()[0] == '/') { String tmp = cp.v()+1; cp = tmp; } char *firstslash = STRCHR(cp, '/'); if (firstslash == NULL) { // host only hostname = cp; return; } else { String tmp = firstslash+1; *firstslash = '\0'; hostname = cp; cp = tmp; } colon = STRCHR(hostname, ':'); // reusing if (colon != NULL) { *colon = '\0'; port = ATOI(colon+1); if (port == 0) port = 80; } if (!cp.isempty()) { char *lastslash; for (lastslash = (char*)cp.v(); *lastslash; lastslash++) { } // go to end // back up to last slash or beginning for (; lastslash > (char*)cp.v() && *lastslash != '/'; lastslash--) { } if (*lastslash == '/') { resource = lastslash+1; *lastslash = '\0'; path = cp; } else { resource = cp; // no more slashes, just the filename->no path // path is already NULL } } // resolveDotDot(); }
void DriverStation::setProtocol (ProtocolType protocol) { if (protocol == kProtocol2015) { m_protocol = new DS_Protocol2015; setProtocol (m_protocol); } if (protocol == kProtocol2016) { m_protocol = new DS_Protocol2016; setProtocol (m_protocol); } }
void UniformResourceIdentifier::set(const char* str) { if (mReferences == 0) { mURI = NxOgre_New(URIHash)(); mReferences = (unsigned short*) NxOgre_Allocate(sizeof(unsigned short), Classes::_BufferReferenceCounter); (*mReferences) = 1; } // Split up protocol and location here. unsigned int str_length = Functions::getCStringLength(str); unsigned int colonPosition = -1; for (unsigned int i=0;i < str_length;i++) { if (str[i] == ':') { colonPosition = i; break; } } if (colonPosition == -1) return; setProtocol(str, 0, colonPosition); if (colonPosition + 1 != str_length) setLocation(str, colonPosition + 1, str_length - colonPosition - 1); }
void gajim::loadMessages(const QString &path) { QDir dir = path; QFileInfo info(dir.filePath("logs.db")); if(!info.exists()) return; QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(info.absoluteFilePath()); if(!db.open()) return; setProtocol("jabber"); setAccount(m_account); QSqlQuery jid_query("SELECT jid_id, jid FROM jids", db); setMaxValue(jid_query.size()); int num = 0; while(jid_query.next()) { QString jid_id = jid_query.value(0).toString(); QString jid = jid_query.value(1).toString(); setContact(jid); static QString query_str = "SELECT time, message, kind FROM logs " "WHERE jid_id = %1 AND (kind = 4 OR kind = 6) " "ORDER BY time ASC"; QSqlQuery query(query_str.arg(jid_id), db); while(query.next()) { Message message; message.setTime(QDateTime::fromTime_t(query.value(0).toInt())); message.setIncoming(query.value(2).toInt() == 4); message.setText(query.value(1).toString()); appendMessage(message); } setValue(++num); } }
PubSubClient::PubSubClient() { this->_state = MQTT_DISCONNECTED; this->_client = NULL; this->stream = NULL; setCallback(NULL); setProtocol(MQTT_VERSION); }
PubSubClient::PubSubClient(const char* domain, uint16_t port, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(domain,port); setClient(client); setStream(stream); setProtocol(MQTT_VERSION); }
SipAccount::SipAccount(const std::string & username,const std::string & userid, const std::string & password, const std::string & realm, const std::string & registerservername, unsigned registerserverport, const std::string & SIPproxyservername, unsigned SIPproxyserverport, bool rememberPasswod, bool enablePIM, bool rememberUsername, bool autoLoginVoxOx) { initVars(); setProtocol( EnumIMProtocol::IMProtocolSIP ); _identity = userid; _username = username; _realm = realm; _password = password; _imPassword = password; //VOXOX - JRT - 2009.09.25 - SIP/Jabber password separation. Will get actual password from SSO. _registerServerHostname = registerservername; _registerServerPort = registerserverport; _sipProxyServerHostname = SIPproxyservername; _sipProxyServerPort = SIPproxyserverport; _enablePIM = enablePIM; _rememberPassword = rememberPasswod; _rememberUsername = rememberUsername; _autoLoginVoxOx = autoLoginVoxOx; //VOXOX - JRT - 2009.09.07 - These are already set in new initVars(). // _voicemail = "*98"; // _discoveringNetwork = false; // _lastNetworkDiscoveryState = NetworkDiscoveryStateError; // _initSuccessful = false; // _initTimerCounter = 0; // _initTimer.lastTimeoutEvent += boost::bind(&SipAccount::initLastTimeoutEventHandler, this); }
bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol) { Q_D(QHttpSocketEngine); if (type != QAbstractSocket::TcpSocket) return false; setProtocol(protocol); setSocketType(type); d->socket = new QTcpSocket(this); // Explicitly disable proxying on the proxy socket itself to avoid // unwanted recursion. QNetworkProxy proxy; proxy.setType(QNetworkProxy::NoProxy); d->socket->setProxy(proxy); // Intercept all the signals. connect(d->socket, SIGNAL(connected()), this, SLOT(slotSocketConnected())); connect(d->socket, SIGNAL(disconnected()), this, SLOT(slotSocketDisconnected())); connect(d->socket, SIGNAL(readyRead()), this, SLOT(slotSocketReadNotification())); connect(d->socket, SIGNAL(readyRead()), this, SLOT(slotSocketReadNotification())); connect(d->socket, SIGNAL(bytesWritten(qint64)), this, SLOT(slotSocketBytesWritten())); connect(d->socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError))); connect(d->socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(slotSocketStateChanged(QAbstractSocket::SocketState))); return true; }
MMulticastSocketDevice::MMulticastSocketDevice( QString sAddress, quint16 nPort, u_char ttl) : MSocketDevice(MSocketDevice::Datagram), m_address(sAddress), m_port(nPort) { #if 0 ttl = UPnp::GetConfiguration()->GetValue( "UPnP/TTL", 4 ); #endif if (ttl == 0) ttl = 4; setProtocol(IPv4); setSocket(createNewSocket(), MSocketDevice::Datagram); m_imr.imr_multiaddr.s_addr = inet_addr(sAddress.toLatin1().constData()); m_imr.imr_interface.s_addr = htonl(INADDR_ANY); if (setsockopt(socket(), IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *)&m_imr, sizeof( m_imr )) < 0) { LOG(VB_GENERAL, LOG_ERR, LOC + "setsockopt - IP_ADD_MEMBERSHIP " + ENO); } if (setsockopt(socket(), IPPROTO_IP, IP_MULTICAST_TTL, (const char *)&ttl, sizeof(ttl)) < 0) { LOG(VB_GENERAL, LOG_ERR, LOC + "setsockopt - IP_MULTICAST_TTL " + ENO); } setAddressReusable(true); if (!bind(m_address, m_port)) LOG(VB_GENERAL, LOG_ERR, LOC + "bind failed"); }
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(ip,port); setClient(client); setStream(stream); setProtocol(MQTT_VERSION); }
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, Client& client) { this->_state = MQTT_DISCONNECTED; setServer(addr, port); setClient(client); this->stream = NULL; setProtocol(MQTT_VERSION); }
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(ip,port); setCallback(callback); setClient(client); setStream(stream); setProtocol(MQTT_VERSION); }
PubSubClient::PubSubClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) { this->_state = MQTT_DISCONNECTED; setServer(domain,port); setCallback(callback); setClient(client); this->stream = NULL; setProtocol(MQTT_VERSION); }
IMAddressLVI::IMAddressLVI( QTreeWidget *parent, const KPluginInfo &protocol, const QString &address, const IMContext &context ) : QTreeWidgetItem( parent ) { setProtocol( protocol ); setAddress( address ); setContext( context ); mPreferred = false; }
void andrq::loadMessages(const QString &path) { QDir dir = path; QString account = dir.dirName(); if(!dir.cd("history")) return; setProtocol("ICQ"); setAccount(account); QFileInfoList files = dir.entryInfoList(QDir::Files); setMaxValue(files.size()); for(int i = 0; i < files.size(); i++) { setValue(i + 1); QString uin = files[i].fileName(); QFile file(files[i].absoluteFilePath()); if(!file.open(QFile::ReadOnly)) continue; setContact(uin); QDataStream in(&file); in.setByteOrder(QDataStream::LittleEndian); Message message; message.type=1; while(!in.atEnd()) { qint32 type; in >> type; switch(type) { case -1: { quint8 kind; qint32 who; in >> kind >> who; QString from = QString::number(who); message.in = from == uin; message.time = getDateTime(in); qint32 tmp; in >> tmp; in.skipRawData(tmp); message.text = Qt::escape(getString(in, who)).replace("\n", "<br/>"); if(kind==1) appendMessage(message); break; } case -2: { qint32 tmp; in >> tmp; in.skipRawData(tmp); break; } case -3: in.skipRawData(5); break; default: break; } } } }
void Preferences::readSettings() { /* Load protocol version & team number */ setProtocol (Settings::get ("Protocol", 0).toInt()); setTeamNumber (Settings::get ("Team", 0).toInt()); m_teamNumber->setValue (Settings::get ("Team", 0).toInt()); m_protocols->setCurrentIndex (Settings::get ("Protocol", 0).toInt()); /* Load the practice timings into the UI */ loadPracticeValues(); }
void HRCSwitch::send(unsigned long remote, unsigned long button, boolean onoff){ int lastprotocol = this->nProtocol; int lastRepeatTransmit = this->nRepeatTransmit; setProtocol(4); setRepeatTransmit(1); char* remote_bin = this->dec2binWzerofill(remote, 26); char* button_bin = this->dec2binWzerofill2(button, 4); //Serial.println(this->dec2binWzerofill(remote, 26)); //char* remote_bin = (this->dec2binWcharfill(remote, 26, '0')); //char* button_bin = (this->dec2binWcharfill(button, 4, '0')); Serial.println(remote_bin); Serial.println(button_bin); //Set Protocol to Home Easy (Chacon/DIO) //Latch1 this->transmit(1,36); //Latch2 this->transmit(1,10); digitalWrite(this->nTransmitterPin, HIGH); //Remote (Recipient Code) this->send(remote_bin); //No Group this->sendPair(false); //ON/OFF this->sendPair(onoff); //Button (Sender Code) this->send(button_bin); //End Message this->send0(); delay(10); setProtocol(lastprotocol); setRepeatTransmit(lastRepeatTransmit); }
void NSPluginInstance::doLoadPlugin() { if (!inited) { delete _button; _button = 0L; _loader = NSPluginLoader::instance(); setBackgroundMode(QWidget::NoBackground); WId winid = stub->winId(); if( winid != 0 ) { setProtocol(QXEmbed::XPLAIN); embed( winid ); } else { setProtocol(QXEmbed::XEMBED); } // resize before showing, some plugins are stupid and can't handle repeated // NPSetWindow() calls very well (viewer will avoid the call if not shown yet) resizePlugin(width(), height()); displayPlugin(); show(); inited = true; } }
void Preferences::readSettings() { /* Load saved values in widgets */ m_teamNumber->setValue (Settings::get ("Team", 0).toInt()); m_protocols->setCurrentIndex (Settings::get ("Protocol", 0).toInt()); /* Redundant but safer, configure DS again directly */ setProtocol (m_protocols->currentIndex()); setTeamNumber (m_teamNumber->value()); /* Load the practice timings into the UI */ loadPracticeValues(); }
EngineConfiguration::EngineConfiguration(const QVariant& variant) : m_variants(QStringList() << "standard"), m_whiteEvalPov(false), m_pondering(false), m_validateClaims(true), m_restartMode(RestartAuto) { const QVariantMap map = variant.toMap(); setName(map["name"].toString()); setCommand(map["command"].toString()); setWorkingDirectory(map["workingDirectory"].toString()); setStderrFile(map["stderrFile"].toString()); setProtocol(map["protocol"].toString()); if (map.contains("initStrings")) setInitStrings(map["initStrings"].toStringList()); if (map.contains("whitepov")) setWhiteEvalPov(map["whitepov"].toBool()); if (map.contains("ponder")) setPondering(map["ponder"].toBool()); if (map.contains("restart")) { const QString val(map["restart"].toString()); if (val == "auto") setRestartMode(RestartAuto); else if (val == "on") setRestartMode(RestartOn); else if (val == "off") setRestartMode(RestartOff); } if (map.contains("validateClaims")) setClaimsValidated(map["validateClaims"].toBool()); if (map.contains("variants")) setSupportedVariants(map["variants"].toStringList()); if (map.contains("options")) { const QVariantList optionsList = map["options"].toList(); EngineOption* option = nullptr; foreach (const QVariant& optionVariant, optionsList) { if ((option = EngineOptionFactory::create(optionVariant.toMap())) != nullptr) addOption(option); } } }
void WebSslInfo::fromMetaData(const QVariant& value) { if (value.isValid() && value.type() == QVariant::Map) { QMap<QString, QVariant> metaData = value.toMap(); if (metaData.value("ssl_in_use", false).toBool()) { setCertificateChain(metaData.value("ssl_peer_chain").toByteArray()); setPeerAddress(metaData.value("ssl_peer_ip").toString()); setParentAddress(metaData.value("ssl_parent_ip").toString()); setProtocol(metaData.value("ssl_protocol_version").toString()); setCiphers(metaData.value("ssl_cipher").toString()); setCertificateErrors(metaData.value("ssl_cert_errors").toString()); setUsedCipherBits(metaData.value("ssl_cipher_used_bits").toString()); setSupportedCipherBits(metaData.value("ssl_cipher_bits").toString()); } } }
QMulticastSocket::QMulticastSocket( QString sAddress, quint16 nPort, quint8 ttl ) : MSocketDevice( MSocketDevice::Datagram ) { m_address.setAddress( sAddress ); m_port = nPort; // ttl = UPnp::GetConfiguration()_pConfig->GetValue( "UPnP/TTL", 4 ); if (ttl == 0) ttl = 4; // Force to IPv4 until a proper upnp spec is complete for ipv6 as well. setProtocol(IPv4); setSocket(createNewSocket(), MSocketDevice::Datagram); // ---------------------------------------------------------------------- // Set the numer of subnets to traverse (TTL) // ---------------------------------------------------------------------- setsockopt( socket(), IPPROTO_IP, IP_MULTICAST_TTL, (char *)(&ttl), sizeof(ttl) ); setAddressReusable( true ); // ---------------------------------------------------------------------- // bind to the local address/port (win32 requires QHostAddress::Any be used // ---------------------------------------------------------------------- if (bind( QHostAddress::Any, m_port ) == false) VERBOSE(VB_IMPORTANT, QString( "QMulticastSocket: bind failed (%1)" ).arg( GET_SOCKET_ERROR )); // ---------------------------------------------------------------------- // Now join the Multicast group // ---------------------------------------------------------------------- QByteArray addr = sAddress.toLatin1(); struct ip_mreq imr; imr.imr_multiaddr.s_addr = inet_addr( addr.constData() ); imr.imr_interface.s_addr = htonl(INADDR_ANY); if ( setsockopt( socket(), IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)(&imr), sizeof( imr )) != 0) VERBOSE(VB_IMPORTANT, QString( "QMulticastSocket: setsockopt - IP_ADD_MEMBERSHIP Error (%1)" ).arg( GET_SOCKET_ERROR )); }
void psi::loadMessages(const QString &path) { QDir dir = path; if(!dir.cd("history")) return; QFileInfoList files = dir.entryInfoList(QStringList() << "*.history", QDir::Files); setProtocol("jabber"); setAccount(m_account); setMaxValue(files.size()); for(int i = 0; i < files.size(); i++) { setValue(i + 1); QString contact = files[i].fileName(); contact.chop(4); contact = decode(contact); setContact(contact); QFile file(files[i].absoluteFilePath()); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) continue; QTextStream in(&file); in.setCodec("utf-8"); while(!in.atEnd()) { static const QChar c('|'); QString line = in.readLine(); if(line.isEmpty()) continue; // |2008-07-13T15:27:57|5|from|N3--|Цитата #397796|http://bash.org.ru/quote/397796|Цитата #397796|xxx: cool text Message message; message.setTime(QDateTime::fromString(line.section(c, 1, 1), Qt::ISODate)); message.setIncoming(line.section(c, 3, 3) == "from"); QString text = line.mid(line.lastIndexOf(c) + 1); int psi_type = line.section(c, 2, 2).toInt(); if(psi_type == 2 || psi_type == 3 || psi_type == 6 || psi_type == 7 || psi_type == 8 || text.isEmpty()) continue; message.setText(logdecode(text)); appendMessage(message); } } }
bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol) { Q_D(QHttpSocketEngine); if (type != QAbstractSocket::TcpSocket) return false; setProtocol(protocol); setSocketType(type); d->socket = new QTcpSocket(this); d->reply = new QHttpNetworkReply(QUrl(), this); #ifndef QT_NO_BEARERMANAGEMENT d->socket->setProperty("_q_networkSession", property("_q_networkSession")); #endif // Explicitly disable proxying on the proxy socket itself to avoid // unwanted recursion. d->socket->setProxy(QNetworkProxy::NoProxy); // Intercept all the signals. connect(d->socket, SIGNAL(connected()), this, SLOT(slotSocketConnected()), Qt::DirectConnection); connect(d->socket, SIGNAL(disconnected()), this, SLOT(slotSocketDisconnected()), Qt::DirectConnection); connect(d->socket, SIGNAL(readyRead()), this, SLOT(slotSocketReadNotification()), Qt::DirectConnection); connect(d->socket, SIGNAL(bytesWritten(qint64)), this, SLOT(slotSocketBytesWritten()), Qt::DirectConnection); connect(d->socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError)), Qt::DirectConnection); connect(d->socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(slotSocketStateChanged(QAbstractSocket::SocketState)), Qt::DirectConnection); return true; }
/* {{{ MySQL_Uri::setHost() -I- */ void MySQL_Uri::setHost(const sql::SQLString &h) { setProtocol(NativeAPI::PROTOCOL_TCP); host= h.c_str(); }
/* {{{ MySQL_Uri::setPort() -I- */ void MySQL_Uri::setPort(unsigned int p) { setProtocol(NativeAPI::PROTOCOL_TCP); port= p; }
/* {{{ MySQL_Uri::setPipe() -I- */ void MySQL_Uri::setPipe(const sql::SQLString &p) { setProtocol(NativeAPI::PROTOCOL_PIPE); host= p.c_str(); }
/* {{{ MySQL_Uri::setSocket() -I- */ void MySQL_Uri::setSocket(const sql::SQLString &s) { setProtocol(NativeAPI::PROTOCOL_SOCKET); host= s.c_str(); }
void qipinfium::loadMessages(const QString &path) { QDir dir = path; if(!dir.cd("History")) return; QHash<QString,QString> protocols; protocols[QLatin1String("icq")] = QLatin1String("ICQ"); protocols[QLatin1String("jabber")] = QLatin1String("Jabber"); protocols[QLatin1String("mra")] = QLatin1String("MRIM"); QStringList filters; foreach(QString format,protocols.keys()) filters << (format + QLatin1String("*.qhf")) << (format + QLatin1String("*.ahf")); QFileInfoList files = dir.entryInfoList(filters, QDir::Files); setMaxValue(files.size()); for(int i = 0; i < files.size(); i++) { setValue(i + 1); QString protocol = files[i].fileName().section("_",0,0); while(!protocol.isEmpty() && protocol.at(protocol.length() - 1).isDigit()) protocol.chop(1); protocol = protocols[protocol.toLower()]; if(protocol.isEmpty()) { warning() << "Unknown protocol: " << files[i].fileName(); continue; } setProtocol(protocol); setAccount(m_accounts.value(protocol)); QFile file(files[i].absoluteFilePath()); if(file.open(QFile::ReadOnly)) { QByteArray bytearray = file.readAll(); const uchar *data = (const uchar *)bytearray.constData(); const uchar *end = data + bytearray.size(); if(memcmp(data, "QHF", 3)) continue; uchar version = data[3]; data += 44; QString uin = getString(data, getUInt16(data)); QString name = getString(data, getUInt16(data)); Q_UNUSED(name); QDateTime time; setContact(uin); while(data < end) { quint16 type = getUInt16(data); quint32 index = getUInt32(data); data += 2; if(type == 1) { Message message; data += 10; time = QDateTime::fromTime_t(getUInt32(data)); time.setTimeSpec(Qt::LocalTime); if(version == 1) time = time.toUTC().addDays(2); else time = time.toUTC(); message.setTime(time); data += 4; message.setIncoming(getUInt8(data) == 0); data += 4; int mes_len = version == 3 ? getUInt32(data) : getUInt16(data); message.setText(getString(data, mes_len, version > 1)); appendMessage(message); } else data += index; } } } }