void tvNetworkControl::sendIDPacket(const QString &remoteIP, const QString &ID, const QString &name)
{
    const char packetStart[] = {
        0x00, 0x13, 0x00, 0x69, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x2e, 0x69, 0x61, 0x70, 0x70, 0x2e, 0x73,
        0x61, 0x6d, 0x73, 0x75, 0x6e, 0x67
    };

    const QByteArray remoteIPEncoded = encodeString(remoteIP);
    const QByteArray remoteIDEncoded = encodeString(ID);
    const QByteArray remoteNameEncoded = encodeString(name);

    const char payLoadStart[] = {
        0x64, 0x00
    };

    QByteArray payLoad;
    payLoad.append(QByteArray::fromRawData(payLoadStart, sizeof(payLoadStart)));
    payLoad.append(QByteArray::fromRawData(remoteIPEncoded.data(), remoteIPEncoded.size()));
    payLoad.append(QByteArray::fromRawData(remoteIDEncoded.data(), remoteIDEncoded.size()));
    payLoad.append(QByteArray::fromRawData(remoteNameEncoded.data(), remoteNameEncoded.size()));
    const qint16 payLoadSize = payLoad.size();

    QByteArray packet;
    QDataStream stream(&packet, QIODevice::WriteOnly);
    stream.writeRawData(packetStart, sizeof(packetStart));
    stream.setByteOrder(QDataStream::LittleEndian);
    stream << payLoadSize;
    stream.setByteOrder(QDataStream::BigEndian);
    stream.writeRawData(payLoad, payLoadSize);

    if (m_socket) {
        emit logText(tr("=========== <b>Send ID Datagram</b> ===========<br>%1").arg(byteArrayToHexaString(packet)));
        sendRaw(packet);
    }
}
Example #2
0
void Multiplex7Seg::setTimer(time_t secs, bool dot)
{
  int mins = secs / 60;
  secs %= 60;
  
  if (mins > 60)
  {
    encodeString("OFL");
  }
  else
  {
    char *sp = buffer;
    *sp++ = ' ';
    
    if (dot)
      *sp++ = '.';
    
    *sp++ = (mins / 10) + '0';
    *sp++ = (mins % 10) + '0';

      
    *sp++ = 0;
    
    encodeString(buffer);
    
    /*
    
    byte secdial = dial[secs / 10];
    
    digits[2] = mapSegments(secdial);
    */
  }
}
void ICQClient::sendCapability(const QString &away_msg)
{
    Buffer cap;
    capability c;

    memcpy(c, capabilities[CAP_SIM], sizeof(c));
    const char *ver = VERSION;
    unsigned char *pack_ver = c + sizeof(capability) - 4;
    *(pack_ver++) = get_ver(ver);
    *(pack_ver++) = get_ver(ver);
    *(pack_ver++) = get_ver(ver);
    unsigned char os_ver;
#ifdef WIN32
    os_ver = 0x80;
#else
#ifdef QT_MACOSX_VERSION
    os_ver = 0x40;
#else
    os_ver = 0;
#endif
#endif
    *(pack_ver++) = os_ver;
    addCapability(cap, CAP_AIM_SHORTCAPS);
    addCapability(cap, CAP_AIM_SUPPORT);
//    addCapability(cap, CAP_AVATAR);
    if (m_bAIM){
        addCapability(cap, CAP_AIM_CHAT);
        addCapability(cap, CAP_AIM_BUDDYCON);
        addCapability(cap, CAP_AIM_IMIMAGE);
        addCapability(cap, CAP_AIM_SENDFILE);
        addCapability(cap, CAP_AIM_BUDDYLIST);
    }else{
        addCapability(cap, CAP_DIRECT);
        addCapability(cap, CAP_SRV_RELAY);
        addCapability(cap, CAP_XTRAZ);
        if (getSendFormat() <= 1)
            addCapability(cap, CAP_UTF);
        if (getSendFormat() == 0)
            addCapability(cap, CAP_RTF);
    }
    if (!getDisableTypingNotification())
        cap.pack((char*)capabilities[CAP_TYPING], sizeof(capability));

    cap.pack((char*)c, sizeof(c));
    snac(ICQ_SNACxFAM_LOCATION, ICQ_SNACxLOC_SETxUSERxINFO);
    if (m_bAIM){
        if (data.owner.ProfileFetch.bValue){
            QString profile;
            profile = QString("<HTML>") + data.owner.About.ptr + "</HTML>";
            encodeString(profile, "text/aolrtf", 1, 2);
        }
        if (!away_msg.isNull())
            encodeString(away_msg, "text/plain", 3, 4);
    }
    m_socket->writeBuffer.tlv(0x0005, cap);
    if (m_bAIM)
        m_socket->writeBuffer.tlv(0x0006, "\x00\x04\x00\x02\x00\x02", 6);
    sendPacket(true);
}
Example #4
0
void ICQClient::sendCapability(const char *away_msg)
{
    Buffer cap;
    capability c;
    memcpy(c, capabilities[CAP_SIM], sizeof(c));
    const char *ver = VERSION;
    unsigned char *pack_ver = c + sizeof(capability) - 4;
    *(pack_ver++) = get_ver(ver);
    *(pack_ver++) = get_ver(ver);
    *(pack_ver++) = get_ver(ver);
    unsigned char os_ver;
#ifdef WIN32
    os_ver = 0x80;
#else
#ifdef QT_MACOSX_VERSION
    os_ver = 0x40;
#else
    os_ver = 0;
#endif
#endif
    *(pack_ver++) = os_ver;
    if (m_bAIM) {
        cap.pack((char*)capabilities[CAP_AIM_CHAT], sizeof(capability));
        cap.pack((char*)capabilities[CAP_AIM_BUDDYCON], sizeof(capability));
        cap.pack((char*)capabilities[CAP_AIM_IMIMAGE], sizeof(capability));
        cap.pack((char*)capabilities[CAP_AIM_SENDFILE], sizeof(capability));
        cap.pack((char*)capabilities[CAP_AIM_BUDDYLIST], sizeof(capability));
    } else {
        cap.pack((char*)capabilities[CAP_DIRECT], sizeof(capability));
        cap.pack((char*)capabilities[CAP_SRV_RELAY], sizeof(capability));
        if (getSendFormat() <= 1)
            cap.pack((char*)capabilities[CAP_UTF], sizeof(capability));
        if (getSendFormat() == 0)
            cap.pack((char*)capabilities[CAP_RTF], sizeof(capability));
    }
    if (getTypingNotification())
        cap.pack((char*)capabilities[CAP_TYPING], sizeof(capability));
    cap.pack((char*)capabilities[CAP_AIM_SUPPORT], sizeof(capability));
    cap.pack((char*)c, sizeof(c));
    snac(ICQ_SNACxFAM_LOCATION, ICQ_SNACxLOC_SETxUSERxINFO);
    if (m_bAIM) {
        if (data.owner.ProfileFetch.bValue) {
            QString profile;
            if (data.owner.About.ptr)
                profile = QString::fromUtf8(data.owner.About.ptr);
            profile = QString("<HTML>") + profile + "</HTML>";
            encodeString(profile, "text/aolrtf", 1, 2);
        }
        if (away_msg)
            encodeString(QString::fromUtf8(away_msg), "text/plain", 3, 4);
    }
    m_socket->writeBuffer.tlv(0x0005, cap);
    if (m_bAIM)
        m_socket->writeBuffer.tlv(0x0006, "\x00\x04\x00\x02\x00\x02", 6);
    sendPacket();
}
Example #5
0
//-------------------------------------------------------------------------
// y-func : get_bouquets_as_dropdown [<bouquet>] <doshowhidden>
//-------------------------------------------------------------------------
std::string  CNeutrinoYParser::func_get_bouquets_as_dropdown(CyhookHandler *hh, std::string para)
{
	std::string ynr, yresult, sel, nr_str, do_show_hidden;
	int nr=1;
	
	ySplitString(para," ",nr_str, do_show_hidden);
	if(nr_str != "")
		nr = atoi(nr_str.c_str());

	for (int i = 0; i < (int) g_bouquetManager->Bouquets.size(); i++) {
		sel=(nr==(i+1)) ? "selected=\"selected\"" : "";
		if(!g_bouquetManager->Bouquets[i]->bHidden || do_show_hidden == "true")
			yresult += string_printf("<option value=%u %s>%s</option>\n", i + 1, sel.c_str(), 
				(encodeString(std::string(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) :g_bouquetManager->Bouquets[i]->Name.c_str()))).c_str());
			//yresult += string_printf("<option value=%u %s>%s</option>\n", i + 1, sel.c_str(), (encodeString(std::string(g_bouquetManager->Bouquets[i]->Name.c_str()))).c_str());
	}
#if 0
	for (unsigned int i = 0; i < NeutrinoAPI->BouquetList.size();i++)
	{	
		sel=(nr==(i+1)) ? "selected=\"selected\"" : "";
		if(!NeutrinoAPI->BouquetList[i].hidden || do_show_hidden == "true")
			yresult += string_printf("<option value=%u %s>%s</option>\n", (NeutrinoAPI->BouquetList[i].bouquet_nr) + 1, sel.c_str(), (encodeString(std::string(NeutrinoAPI->BouquetList[i].name))).c_str());
	}
#endif
	return yresult;
}
Example #6
0
void Multiplex7Seg::setFloat(float value)
{
  char buffer[6];
  char *sp = buffer;
  
  int vi = (int)(value *= 10);
  
  int i1 = vi / 100;
  vi %= 100;
  
  int i2 = vi / 10;
  vi %= 10;
  
  if (i1)
    *sp++ = '0' + i1;
  else
    *sp++ = ' ';
    
  *sp++ = '0' + i2;
  *sp++ = '.';
  
  *sp++ = '0' + vi;
  
  *sp++ = 0;
  
  encodeString(buffer);  
}
  bool
encodeValue(valueType *value)
{
	switch (value->kindOfValue) {
		case ABSOLUTE_VALUE:
			return(encodeNumber(value->value));

		case RELOCATABLE_VALUE:
			return(encodeRelocatableNumber(value->value));

		case OPERAND_VALUE:
			return(encodeOperand(value->value));

		case STRING_VALUE:
			return(encodeString(value->value));

		case CONDITION_VALUE:
			return(encodeCondition(value->value));

		case DATA_VALUE:
		case BSS_VALUE:
		case STRUCT_VALUE:
		case FIELD_VALUE:
		case MACRO_VALUE:
		case UNDEFINED_VALUE:
		case FUNCTION_VALUE:
		case BLOCK_VALUE:
		case BUILT_IN_FUNCTION_VALUE:
		case ARRAY_VALUE:
		case FAIL:
			error(WRONG_KIND_OF_VALUE_IN_OBJECT_EXPRESSION_ERROR,
				valueKindString(value->kindOfValue));
			return(FALSE);
	}
}
  bool
encodeOperand(operandType *operand)
{
	switch (operand->kindOfOperand) {
		case EXPRESSION_OPND:
		case IMMEDIATE_OPND:
		case INDIRECT_OPND:
		case POST_INDEXED_Y_OPND:
		case PRE_INDEXED_X_OPND:
		case X_INDEXED_OPND:
		case Y_INDEXED_OPND:
			return(encodeExpression(operand->theOperand.expressionUnion));

		case A_REGISTER_OPND:
		case X_REGISTER_OPND:
		case Y_REGISTER_OPND:
			error(REGISTER_OPERAND_IN_OBJECT_EXPRESSION_ERROR);
			return(FALSE);

		case X_SELECTED_OPND:
		case Y_SELECTED_OPND:
		case PRE_SELECTED_X_OPND:
			error(SELECTION_OPERAND_IN_OBJECT_EXPRESSION_ERROR);
			return(FALSE);

		case STRING_OPND:
			return(encodeString(operand->theOperand.stringUnion));

		case BLOCK_OPND:
			error(BLOCK_OPERAND_IN_OBJECT_EXPRESSION_ERROR);
			return(FALSE);
	}
}
Example #9
0
 void addAttribute (char * name, char * value) {
     int id = getTagId (name); // create the entry if necessary
     if (m_dumpTable) {
         encodeSize (id+1);
         encodeString (value);
     }
 }
void ICQClient::setAIMInfo(ICQUserData *data)
{
    if (getState() != Connected)
        return;
    bool bWide = isWide(data->FirstName.ptr) ||
                 isWide(data->LastName.ptr) ||
                 isWide(data->MiddleName.ptr) ||
                 isWide(data->Maiden.ptr) ||
                 isWide(data->Nick.ptr) ||
                 isWide(data->Zip.ptr) ||
                 isWide(data->Address.ptr) ||
                 isWide(data->City.ptr);
    string country;
    for (const ext_info *e = getCountryCodes(); e->szName; e++){
        if (e->nCode == data->Country.value){
            country = e->szName;
            break;
        }
    }
    snac(ICQ_SNACxFAM_LOCATION, ICQ_SNACxLOC_SETxDIRxINFO);
    string encoding = bWide ? "unicode-2-0" : "us-ascii";
    m_socket->writeBuffer.tlv(0x1C, encoding.c_str());
    m_socket->writeBuffer.tlv(0x0A, (unsigned short)0x01);
    encodeString(data->FirstName.ptr, 0x01, bWide);
    encodeString(data->LastName.ptr, 0x02, bWide);
    encodeString(data->MiddleName.ptr, 0x03, bWide);
    encodeString(data->Maiden.ptr, 0x04, bWide);
    encodeString(country.c_str(), 0x06, bWide);
    encodeString(data->Address.ptr, 0x07, bWide);
    encodeString(data->City.ptr, 0x08, bWide);
    encodeString(data->Nick.ptr, 0x0C, bWide);
    encodeString(data->Zip.ptr, 0x0D, bWide);
    encodeString(data->State.ptr, 0x21, bWide);
    sendPacket(false);

    ICQUserData *ownerData = &this->data.owner;
    set_str(&ownerData->FirstName.ptr, data->FirstName.ptr);
    set_str(&ownerData->LastName.ptr, data->LastName.ptr);
    set_str(&ownerData->MiddleName.ptr, data->MiddleName.ptr);
    set_str(&ownerData->Maiden.ptr, data->Maiden.ptr);
    set_str(&ownerData->Address.ptr, data->Address.ptr);
    set_str(&ownerData->City.ptr, data->City.ptr);
    set_str(&ownerData->Nick.ptr, data->Nick.ptr);
    set_str(&ownerData->Zip.ptr, data->Zip.ptr);
    set_str(&ownerData->State.ptr, data->State.ptr);
    ownerData->Country.value = data->Country.value;
}
Example #11
0
int64_t LogEncoderDecoder::encodeLogHeader(char *dest,
                                           const std::string &recoveryId,
                                           const std::string &senderIp,
                                           int64_t config) {
  // increment by 2 bytes to later store the total length
  char *ptr = dest + sizeof(int16_t);
  int64_t size = 0;
  ptr[size++] = TransferLogManager::HEADER;
  encodeInt(ptr, size, timestampInMicroseconds());
  encodeInt(ptr, size, TransferLogManager::LOG_VERSION);
  encodeString(ptr, size, recoveryId);
  encodeString(ptr, size, senderIp);
  encodeInt(ptr, size, config);

  folly::storeUnaligned<int16_t>(dest, size);
  return (size + sizeof(int16_t));
}
Example #12
0
 void dumpTable () {
     Tag * tag = m_tags;
     encodeSize (m_nbTags);
     while (tag != NULL) {
         encodeString (tag->m_name);
         tag = tag->m_next;
     }
 }
void ICQClient::setAwayMessage(const char *msg)
{
    snac(ICQ_SNACxFAM_LOCATION, ICQ_SNACxLOC_SETxUSERxINFO);
    if (msg){
        encodeString(QString::fromUtf8(msg), "text/plain", 3, 4);
    }else{
        m_socket->writeBuffer.tlv(0x0004);
    }
    sendPacket(true);
}
Example #14
0
void SemposScorer::encodeSentence(const str_sentence_t& sentence, sentence_t& encodedSentence)
{
  for (str_sentence_it it = sentence.begin(); it != sentence.end(); ++it) {
    const int tlemma = encodeString(it->first);
    const int sempos = encodeSempos(it->second);
    if (sempos >= 0) {
      encodedSentence.insert(make_pair(tlemma,sempos));
    }
  }
}
void ICQClient::setProfile(ICQUserData *data)
{
    snac(ICQ_SNACxFAM_LOCATION, ICQ_SNACxLOC_SETxUSERxINFO);
    QString profile;
    if (data->About.ptr)
        profile = QString::fromUtf8(data->About.ptr);
    profile = QString("<HTML>") + profile + "</HTML>";
    encodeString(profile, "text/aolrtf", 1, 2);
    sendPacket(false);
}
Example #16
0
/*!
    Creates an accelerator string for the key sequence.
    For instance CTRL+Key_O gives "Ctrl+O". If the key sequence has
    multiple key codes they are returned comma-separated, e.g.
    "Alt+X, Ctrl+Y, Z". The strings, "Ctrl", "Shift", etc. are
    translated (using QObject::tr()) in the "QAccel" scope. If the key
    sequence has no keys, QString::null is returned.

    On Mac OS X, the string returned resembles the sequence that is shown in
    the menubar.
*/
QKeySequence::operator QString() const
{
    int end = count();
    if ( !end ) return QString::null;

    QString complete;
    int i = 0;
    while ( i < end ) {
        complete += encodeString( d->key[i] );
        i++;
        if ( i != end)
            complete += ", ";
    }
    return complete;
}
Example #17
0
int64_t LogEncoderDecoder::encodeFileCreationEntry(char *dest,
                                                   const std::string &fileName,
                                                   const int64_t seqId,
                                                   const int64_t fileSize) {
  // increment by 2 bytes to later store the total length
  char *ptr = dest + sizeof(int16_t);
  int64_t size = 0;
  ptr[size++] = TransferLogManager::FILE_CREATION;
  encodeInt(ptr, size, timestampInMicroseconds());
  encodeString(ptr, size, fileName);
  encodeInt(ptr, size, seqId);
  encodeInt(ptr, size, fileSize);

  folly::storeUnaligned<int16_t>(dest, size);
  return (size + sizeof(int16_t));
}
Example #18
0
void SshOutgoingPacket::generateQueryPublicKeyPacket(const QByteArray &user,
        const QByteArray &service, const QByteArray &publicKey)
{
    // Name extraction cannot fail, we already verified this when receiving the key
    // from the agent.
    const QByteArray algoName = SshPacketParser::asString(publicKey, quint32(0));
    SshOutgoingPacket packetToSign(m_encrypter, m_seqNr);
    packetToSign.init(SSH_MSG_USERAUTH_REQUEST).appendString(user).appendString(service)
            .appendString("publickey").appendBool(true).appendString(algoName)
            .appendString(publicKey);
    const QByteArray &dataToSign
            = encodeString(m_encrypter.sessionId()) + packetToSign.m_data.mid(PayloadOffset);
    SshAgent::storeDataToSign(publicKey, dataToSign, qHash(m_encrypter.sessionId()));
    init(SSH_MSG_USERAUTH_REQUEST).appendString(user).appendString(service)
            .appendString("publickey").appendBool(false).appendString(algoName)
            .appendString(publicKey).finalize();
}
Example #19
0
/*
 * Send data to the other end
 * @parm data data to send; must be void*
 * @parm type type of data to send
 */
int send(void* data, enum msgType type) {
	if(data == NULL) return -1;
	switch(type) {
	case STRING:
		encodeString((char*)data, com.sendPackets);
		break;
	case CMD:
		break;
	case PLAYLIST:
		break;
	case AUDIO:
		break;
	default:
		return -1;
	}
	com.isRdySend = 1;
	return 0;
}
//-------------------------------------------------------------------------
// y-func : get_bouquets_as_dropdown [<bouquet>] <doshowhidden>
//-------------------------------------------------------------------------
std::string  CNeutrinoYParser::func_get_bouquets_as_dropdown(CyhookHandler *, std::string para)
{
	std::string ynr, yresult, sel, nr_str, do_show_hidden;
	int nr=1;

	ySplitString(para," ",nr_str, do_show_hidden);
	if(nr_str != "")
		nr = atoi(nr_str.c_str());

	int mode = NeutrinoAPI->Zapit->getMode();
	for (int i = 0; i < (int) g_bouquetManager->Bouquets.size(); i++) {
		ZapitChannelList * channels = mode == CZapitClient::MODE_RADIO ? &g_bouquetManager->Bouquets[i]->radioChannels : &g_bouquetManager->Bouquets[i]->tvChannels;
		sel=(nr==(i+1)) ? "selected=\"selected\"" : "";
		if(!channels->empty() && (!g_bouquetManager->Bouquets[i]->bHidden || do_show_hidden == "true"))
			yresult += string_printf("<option value=%u %s>%s</option>\n", i + 1, sel.c_str(),
				(encodeString(std::string(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) :g_bouquetManager->Bouquets[i]->Name.c_str()))).c_str());
			//yresult += string_printf("<option value=%u %s>%s</option>\n", i + 1, sel.c_str(), (encodeString(std::string(g_bouquetManager->Bouquets[i]->Name.c_str()))).c_str());
	}
	return yresult;
}
Example #21
0
void EngineShoutcast::updateMetaData() {
    if (!m_pShout || !m_pShoutMetaData)
        return;

    QByteArray baSong = "";
    /**
     * If track has changed and static metadata is disabled
     * Send new metadata to shoutcast!
     * This works only for MP3 streams properly as stated in comments, see shout.h
     * WARNING: Changing OGG metadata dynamically by using shout_set_metadata
     * will cause stream interruptions to listeners
     *
     * Also note: Do not try to include Vorbis comments in OGG packages and send them to stream.
     * This was done in EncoderVorbis previously and caused interruptions on track change as well
     * which sounds awful to listeners.
     * To conlcude: Only write OGG metadata one time, i.e., if static metadata is used.
     */


    //If we use either MP3 streaming or OGG streaming with dynamic update of metadata being enabled,
    //we want dynamic metadata changes
    if (!m_custom_metadata && (m_format_is_mp3 || m_ogg_dynamic_update)) {
        if (m_pMetaData != NULL) {
            QString artist = m_pMetaData->getArtist();
            QString title = m_pMetaData->getTitle();
            QByteArray baSong = encodeString(artist.isEmpty() ? title : artist + " - " + title);
            shout_metadata_add(m_pShoutMetaData, "song",  baSong.constData());
            shout_set_metadata(m_pShout, m_pShoutMetaData);
        }
    } else {
        //Otherwise we might use static metadata
        /** If we use static metadata, we only need to call the following line once **/
        if (m_custom_metadata && !m_firstCall) {
            shout_metadata_add(m_pShoutMetaData, "song",  m_baCustomSong.constData());
            shout_set_metadata(m_pShout, m_pShoutMetaData);
            m_firstCall = true;
        }
    }
}
Example #22
0
    bool Label::getProperty(std::string property, std::string& value) const
    {
        property = toLower(property);

        if (property == "configfile")
            value = getLoadedConfigFile();
        else if (property == "text")
            encodeString(getText(), value);
        else if (property == "textcolor")
            value = "(" + to_string(int(getTextColor().r)) + "," + to_string(int(getTextColor().g)) + "," + to_string(int(getTextColor().b)) + "," + to_string(int(getTextColor().a)) + ")";
        else if (property == "textsize")
            value = to_string(getTextSize());
        else if (property == "backgroundcolor")
            value = "(" + to_string(int(getBackgroundColor().r)) + "," + to_string(int(getBackgroundColor().g)) + "," + to_string(int(getBackgroundColor().b)) + "," + to_string(int(getBackgroundColor().a)) + ")";
        else if (property == "autosize")
            value = m_AutoSize ? "true" : "false";
        else // The property didn't match
            return ClickableWidget::getProperty(property, value);

        // You pass here when one of the properties matched
        return true;
    }
Example #23
0
void SemposScorer::loadWeights(const string& weightsfile)
{
  string line;
  ifstream myfile;
  myfile.open(weightsfile.c_str(), ifstream::in);
  if (myfile.is_open()) {
    while ( myfile.good() ) {
      getline (myfile,line);
      vector<string> fields;
      if (line == "") continue;
      split(line, '\t', fields);
      if (fields.size() != 2) throw std::runtime_error("Bad format of a row in weights file.");
      int encoded = encodeString(fields[0]);
      float weight = atof(fields[1].c_str());
      weightsMap[encoded] = weight;
    }
    myfile.close();
  } else {
    cerr << "Unable to open file "<< weightsfile << endl;
    exit(1);
  }

}
Example #24
0
wxString
cryptString(const wxString &s)
{
    size_t i;
    wxString sRet = wxEmptyString;
    
    if (s.IsEmpty())
        return s;
    
    wxString str = encodeString(s);
    
    if (str.Length() < 32)
        str += dummyString;
    
    // Reverse string
    for (i = (str.Length() - 1); (int)i >= 0; i--)
        sRet += str[i];
    
    if (sRet.Length() < 32)
        sRet += dummyString;
    
    wxChar k = getRandomValidCharFromList();
    int l = (k + sRet.Length()) - 2;
    sRet.Prepend(k);

    for (i = 1; i < sRet.Length(); i++) {
        int j = validChars.Find(sRet[i]);
        if (j == -1)
            return s;
        sRet.SetChar(i, validChars[(j + l * (i + 1)) % validChars.Length()]);
    }

    wxChar c = getRandomValidCharFromList() + 2;
    sRet.Append(c);
    
    return sRet;
}
Example #25
0
//-------------------------------------------------------------------------
// y-func : get_header_data
//-------------------------------------------------------------------------
std::string CyParser::func_get_languages_as_dropdown(CyhookHandler *,
		std::string para) {
	std::string yresult, sel;
	DIR *d;
	struct dirent *dir;

	std::string act_language = CLanguage::getInstance()->language;
	d = opendir((CLanguage::getInstance()->language_dir).c_str());
	if (d != NULL) {
		while ((dir = readdir(d))) {
			if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0)
				continue;
			if (dir->d_type != DT_DIR) {
				sel = (act_language == std::string(dir->d_name)) ? "selected=\"selected\"" : "";
				yresult += string_printf("<option value=%s %s>%s</option>",
						dir->d_name, sel.c_str(), (encodeString(std::string(dir->d_name))).c_str());
				if(para != "nonl")
					yresult += "\n";
			}
		}
		closedir(d);
	}
	return yresult;
}
Example #26
0
 void setLeave (char * l) {
     if (m_dumpTable) {
         encodeChar (3);
         encodeString (l);
     }
 }
//-------------------------------------------------------------------------
// y-func : get_audio_pids_as_dropdown (from controlapi)
// prara: [apid] option value = apid-Value. Default apid-Index
//-------------------------------------------------------------------------
std::string  CNeutrinoYParser::func_get_audio_pids_as_dropdown(CyhookHandler *, std::string para)
{
	std::string yresult;
	static bool init_iso=true;
	bool idx_as_id=true;

	if(para == "apid")
		idx_as_id=false;
	if(init_iso)
	{
		if(_initialize_iso639_map())
			init_iso=false;
	}
	bool eit_not_ok=true;
	CZapitClient::responseGetPIDs pids;

	CSectionsdClient::ComponentTagList tags;
	pids.PIDs.vpid=0;
	NeutrinoAPI->Zapit->getPIDS(pids);

	t_channel_id current_channel = live_channel_id; //NeutrinoAPI->Zapit->getCurrentServiceID();
	CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo;
	sectionsd_getCurrentNextServiceKey(current_channel&0xFFFFFFFFFFFFULL, currentNextInfo);
	if (sectionsd_getComponentTagsUniqueKey(currentNextInfo.current_uniqueKey,tags))
	{
		for (unsigned int i=0; i< tags.size(); i++)
		{
			for (unsigned short j=0; j< pids.APIDs.size(); j++)
			{
				if ( pids.APIDs[j].component_tag == tags[i].componentTag )
				{
 					if(!tags[i].component.empty())
					{
						if(!(isalnum(tags[i].component[0])))
							tags[i].component=tags[i].component.substr(1,tags[i].component.length()-1);
						yresult += string_printf("<option value=%05u>%s</option>\r\n",idx_as_id ? j : pids.APIDs[j].pid,encodeString(tags[i].component).c_str());
					}
					else
					{
						if(!(init_iso))
						{
							strcpy( pids.APIDs[j].desc, _getISO639Description( pids.APIDs[j].desc ) );
						}
			 			yresult += string_printf("<option value=%05u>%s %s</option>\r\n",idx_as_id ? j : pids.APIDs[j].pid,encodeString(std::string(pids.APIDs[j].desc)).c_str(),pids.APIDs[j].is_ac3 ? " (AC3)": " ");
					}
					eit_not_ok=false;
					break;
				}
			}
		}
	}
	if(eit_not_ok)
	{
		unsigned short i = 0;
		for (CZapitClient::APIDList::iterator it = pids.APIDs.begin(); it!=pids.APIDs.end(); it++)
		{
			if(!(init_iso))
			{
				strcpy( pids.APIDs[i].desc, _getISO639Description( pids.APIDs[i].desc ) );
			}
 			yresult += string_printf("<option value=%05u>%s %s</option>\r\n",idx_as_id ? i : it->pid,pids.APIDs[i].desc,pids.APIDs[i].is_ac3 ? " (AC3)": " ");
			i++;
		}
	}

	if(pids.APIDs.empty())
		yresult = "00000"; // shouldnt happen, but print at least one apid
	return yresult;
}
Example #28
0
Vector<char> encodeStringWithLength(const String& s)
{
    Vector<char> ret = encodeVarInt(s.length());
    ret.append(encodeString(s));
    return ret;
}
SshOutgoingPacket &SshOutgoingPacket::appendString(const QByteArray &string)
{
    m_data.append(encodeString(string));
    return *this;
}
Example #30
0
void EngineShoutcast::updateMetaData() {
    if (!m_pShout || !m_pShoutMetaData)
        return;

    /**
     * If track has changed and static metadata is disabled
     * Send new metadata to shoutcast!
     * This works only for MP3 streams properly as stated in comments, see shout.h
     * WARNING: Changing OGG metadata dynamically by using shout_set_metadata
     * will cause stream interruptions to listeners
     *
     * Also note: Do not try to include Vorbis comments in OGG packages and send them to stream.
     * This was done in EncoderVorbis previously and caused interruptions on track change as well
     * which sounds awful to listeners.
     * To conlcude: Only write OGG metadata one time, i.e., if static metadata is used.
     */


    // If we use either MP3 streaming or OGG streaming with dynamic update of
    // metadata being enabled, we want dynamic metadata changes
    if (!m_custom_metadata && (m_format_is_mp3 || m_ogg_dynamic_update)) {
        if (m_pMetaData != NULL) {

            QString artist = m_pMetaData->getArtist();
            QString title = m_pMetaData->getTitle();

            // shoutcast uses only "song" as field for "artist - title".
            // icecast2 supports separate fields for "artist" and "title", 
            // which will get displayed accordingly if the streamingformat and
            // player supports it. ("song" is treated as an alias for "title")
            // 
            // Note (EinWesen): 
            // Currently that seems to be OGG only, although it is no problem 
            // setting both fields for MP3, tested players do not show anything different.
            // Also I do not know about icecast1. To be safe, i stick to the
            // old way for those use cases.
            if (!m_format_is_mp3 && m_protocol_is_icecast2) {
                shout_metadata_add(m_pShoutMetaData, "artist",  encodeString(artist).constData());
                shout_metadata_add(m_pShoutMetaData, "title",  encodeString(title).constData());
            } else {
                QByteArray baSong = encodeString(artist.isEmpty() ? title : artist + " - " + title);
                shout_metadata_add(m_pShoutMetaData, "song",  baSong.constData());
            }
            shout_set_metadata(m_pShout, m_pShoutMetaData);

        }
    } else {
        // Otherwise we might use static metadata
        // If we use static metadata, we only need to call the following line once
        if (m_custom_metadata && !m_firstCall) {

            // see comment above...
            if (!m_format_is_mp3 && m_protocol_is_icecast2) {
                shout_metadata_add(
                        m_pShoutMetaData,"artist",encodeString(m_customArtist).constData());

                shout_metadata_add(
                        m_pShoutMetaData,"title",encodeString(m_customTitle).constData());
            } else {
                QByteArray baCustomSong = encodeString(m_customArtist.isEmpty() ? m_customTitle : m_customArtist + " - " + m_customTitle);
                shout_metadata_add(m_pShoutMetaData, "song", baCustomSong.constData());
            }

            shout_set_metadata(m_pShout, m_pShoutMetaData);
            m_firstCall = true;
        }
    }
}