Пример #1
0
void MediaScannerClient::endFile()
{
#ifndef ANDROID_DEFAULT_CODE   
   ALOGV("endFile mLocaleEncoding:%d \n",mLocaleEncoding);   
    {      
#else
    if (mLocaleEncoding != kEncodingNone) {
#endif         
        int size = mNames->size();
        uint32_t encoding = kEncodingAll;

#ifndef ANDROID_DEFAULT_CODE   
        
        ALOGV("endFile +possibleEncodings size: %d \n",size);     
        //// compute a bit mask containing all possible encodings
        for (int i = 0; i < mNames->size(); i++)
        { 
        	char const*s=mValues->getEntry(i);
		//	if((s[0]==0xFF)|(!ISUTF8(s))){
            encoding = possibleEncodings(s);
            ALOGD("endFile +possibleEncodings: %d \n",encoding);    
			if(!(encoding==0xFFFFFFFF))
            convertValues(encoding,i);
		//}
			
        }

#else
        // compute a bit mask containing all possible encodings
        for (int i = 0; i < mNames->size(); i++)
            encoding &= possibleEncodings(mValues->getEntry(i));

        // if the locale encoding matches, then assume we have a native encoding.
        if (encoding & mLocaleEncoding)
            convertValues(mLocaleEncoding);
#endif

        // finally, push all name/value pairs to the client
        for (int i = 0; i < mNames->size(); i++) {
            status_t status = handleStringTag(mNames->getEntry(i), mValues->getEntry(i));
            if (status) {
                break;
            }
        }
    }
    // else addStringTag() has done all the work so we have nothing to do

    delete mNames;
    delete mValues;
    mNames = NULL;
    mValues = NULL;
}

}  // namespace android
Пример #2
0
int RedefineDlg::checkValid(const QString& type, QString info)
{
  int ret = -1;
  m_okTypeList.clear();
  m_maxCol = m_columnList.count();
  this->enableButtonOk(false);
  convertValues();
  if ((m_priceColumn < 1) || (m_priceColumn >= m_maxCol) ||
      (m_quantityColumn < 1) || (m_quantityColumn >= m_maxCol) ||
      (m_amountColumn < 1) || (m_amountColumn >= m_maxCol)) {
    info = i18n("There is a problem with the columns selected\nfor 'Price', 'Quantity and 'Amount'.\n\
You will need to reselect those columns.");
    ret = suspectType(info);
    return ret;
  }
Пример #3
0
void CWextHW::setScanResults(QList<WextRawScan> wextScanResults) {
	m_scanResults.clear();
	ScanResult scanresult;
	foreach(WextRawScan i, wextScanResults) {
		scanresult.bssid = i.bssid;
		scanresult.ssid = i.ssid;
		scanresult.freq = i.freq;
		scanresult.signal = convertValues(i);
		scanresult.group = i.group;
		scanresult.pairwise = i.pairwise;
		scanresult.keyManagement = i.keyManagement;
		scanresult.protocols = i.protocols;
		scanresult.opmode = i.opmode;
		scanresult.bitrates = i.bitrates;
		m_scanResults.append(scanresult);
	}
void QtPropertyAnimationPrivate::updateMetaProperty()
{
    if (!target || propertyName.isEmpty())
        return;

    if (hasMetaProperty == 0 && !property.isValid()) {
        const QMetaObject *mo = target->metaObject();
        propertyIndex = mo->indexOfProperty(propertyName);
        if (propertyIndex != -1) {
            hasMetaProperty = 1;
            property = mo->property(propertyIndex);
            propertyType = property.userType();
        } else {
            hasMetaProperty = 2;
        }
    }

    if (property.isValid())
        convertValues(propertyType);
}
void MediaScannerClient::endFile()
{
    if (mLocaleEncoding != kEncodingNone) {
        int size = mNames->size();

        // if the locale encoding matches, then assume we have a native encoding.
		convertValues(mLocaleEncoding);

        // finally, push all name/value pairs to the client
        for (int i = 0; i < mNames->size(); i++) {
            if (!handleStringTag(mNames->getEntry(i), mValues->getEntry(i)))
                break;
        }
    }
    // else addStringTag() has done all the work so we have nothing to do

    delete mNames;
    delete mValues;
    mNames = NULL;
    mValues = NULL;
}
/**
  *
  *bugfix for BUG00161497.android original does not support unicode encoded subtitle ,so we need values convert before display subtitle
  *
  ************************************
  *      
  *ActionsCode(author:sunchengzhi, change_code)
  */
status_t TimedTextSRTSource::read(
        int64_t *startTimeUs,
        int64_t *endTimeUs,
        Parcel *parcel,
        const MediaSource::ReadOptions *options) {
    AString text;
    status_t err = getText(options, &text, startTimeUs, endTimeUs);
    if (err != OK) {
        return err;
    }
	//ActionsCode(author:sunchengzhi, bugfix BUG00161497)
	int encoding;
    char mLocaleEncoding[MAX_SUB_LINE_LEN];
    char textbuf[MAX_SUB_LINE_LEN];
    encoding= subEncodingDetect(text.c_str());
    encodingEnumToString(encoding,mLocaleEncoding);
    if (convertValues(text.c_str(),mLocaleEncoding,textbuf) < 0) {
		    return ERROR_MALFORMED;
	}
	text = textbuf;
    CHECK_GE(*startTimeUs, 0);
    extractAndAppendLocalDescriptions(*startTimeUs, text, parcel);
    return OK;
}
Пример #7
0
void CWextHW::readSignalQuality() {
	if ( (m_wextFd == -1) ) {
		return;
	}
	struct iw_range range;
	memset(&range,0,sizeof(struct iw_range));
	int hasRange = 0;
	iwstats stats;
	memset(&stats,0,sizeof(iwstats));
	WextRawScan res;
	/* workaround */
	struct wireless_config wifiConfig;
	memset(&wifiConfig,0,sizeof(struct wireless_config));
	/* Get basic information */ 
	if(iw_get_basic_config(m_wextFd, m_ifname.toAscii().constData(), &wifiConfig) < 0) {
		/* If no wireless name : no wireless extensions */ 
		/* But let's check if the interface exists at all */ 
		struct ifreq ifr;
		memset(&ifr,0,sizeof(struct ifreq)); 
	
		strncpy(ifr.ifr_name, m_ifname.toAscii().data(), IFNAMSIZ); 
		if(ioctl(m_wextFd, SIOCGIFFLAGS, &ifr) < 0) 
			qWarning() << tr("(Wireless Extension) No device present");
		else
			qWarning() << tr("(Wireless Extension) device not supported");
		return;
	}
	qDebug() << "Fetched basic config.";

	//We encode frequency in mhz;
	//kernel encodes as double; (hopefully always in hz)
	//But better test this:
	res.freq = -1;
	if (wifiConfig.has_freq) {
		if ( ( (wifiConfig.freq/1e9) < 10.0 ) && ( (wifiConfig.freq/1e9) > 0.0 ) ) {
			res.freq = (int) (wifiConfig.freq/1e6);
		}
	}
	
	struct iwreq wrq;
	memset(&wrq,0,sizeof(struct iwreq));
	
	/* Get AP address */
	if(iw_get_ext(m_wextFd, m_ifname.toAscii().data(), SIOCGIWAP, &wrq) >= 0) {
		//Add mac address of current ap;
		res.bssid = libnutcommon::MacAddress((ether_addr*)wrq.u.ap_addr.sa_data);
		qDebug() << "Got AP: " << res.bssid.toString();
	}
	
	/* Get ssid */
	quint8 * buffer = new quint8[IW_ESSID_MAX_SIZE];
	memset(buffer, '\0', IW_ESSID_MAX_SIZE);
	wrq.u.essid.pointer = (void *)buffer;
	wrq.u.essid.length = IW_ESSID_MAX_SIZE;
	if(iw_get_ext(m_wextFd, m_ifname.toAscii().data(), SIOCGIWESSID, &wrq) >= 0) {
		if (wrq.u.essid.length > IW_ESSID_MAX_SIZE)
			wrq.u.essid.length = IW_ESSID_MAX_SIZE;
		if (wrq.u.essid.flags) {
			/* Does it have an ESSID index ? */
			if ( wrq.u.essid.pointer && wrq.u.essid.length ) {
				if ( (wrq.u.essid.flags & IW_ENCODE_INDEX) > 1) {
					res.ssid = QString("%1 [%2]").arg(QString::fromAscii((char*) wrq.u.essid.pointer, wrq.u.essid.length), QString::number(wrq.u.essid.flags & IW_ENCODE_INDEX));
				}
				else {
					res.ssid = QString::fromAscii((char*) wrq.u.essid.pointer, wrq.u.essid.length);
				}
			}
			else {
				res.ssid = "N/A";
			}
		}
		qDebug() << "Got ssid: " << res.ssid;
	}
	delete[] buffer;
	
	/* Get bit rate */
	if(iw_get_ext(m_wextFd, m_ifname.toAscii().data(), SIOCGIWRATE, &wrq) >= 0) {
		res.bitrates.append((qint32) wrq.u.bitrate.value);
		qDebug() << "Got bit rate: " << res.bitrates[0];
	}
	
	/* Get Power Management settings */
	wrq.u.power.flags = 0;
	if(iw_get_ext(m_wextFd, m_ifname.toAscii().data(), SIOCGIWPOWER, &wrq) >= 0) {
		qDebug() << "Got power";
	}
	/* workaround */
	
	
	/* Get range stuff */
	qDebug() << QString("Getting range stuff for %1").arg(m_ifname.toAscii().data());
	if (iw_get_range_info(m_wextFd, m_ifname.toAscii().data(), &range) >= 0) {
		hasRange = 1;
		qDebug() << "Success readWirelessInfo getrange" << strerror(errno);
	}
	else { //This is VERY strange: we always get the "operation not permitted" error, although iw_get_range() worked
		qDebug() << QString("Error \"hasRange == 0\" (%1)").arg(strerror(errno));
	}
	res.hasRange = hasRange;
	if (errno == EAGAIN) {
		m_sqTimeOutCount++;
		qDebug() << QString("Getting range stuff failed (%1)").arg(strerror(errno));
		if ( (m_sqTimeOutCount > 10) && m_sqPollrate < 1000) {
			setSignalQualityPollRate(10000);
		}
		else if (m_sqTimeOutCount > 10) { //Fast polling disabled, but still EAGAIN errors
			//Seems the kernel does not care about our calls
			killTimer(m_sqTimerId);
			m_sqTimerId = -1;
		}
		return;
	}
	
	qDebug() << "Got range stuff";
	

	//Set supported Frequencies if the list is not empty;
	if (m_supportedFrequencies.isEmpty() && hasRange) {
		qDebug() << range.num_frequency;
		qDebug() << "Printing Frequency information";
		quint32 m;
		quint16 e;
		quint32 freqinmhz;
		for (int i=0; i < range.num_channels; i++) {
			m = (quint32) range.freq[i].m;
			e = (quint16) range.freq[i].e;
			freqinmhz = m;
			for (int j=0; j < 9-e-3; j++) {
				freqinmhz = freqinmhz/10;
			}
			if (!m_supportedFrequencies.contains(freqinmhz)) { //Only add frequency that are not in our list
				m_supportedFrequencies.append(freqinmhz);
			}
			qDebug() << m << e << freqinmhz << frequencyToChannel(freqinmhz);
		}
		qDebug() << "Done printing";
	}
	else {
		qDebug() << "m_supportedFrequencies not set";
	}
	
	if (hasRange) {
		res.maxquality.level = (quint8) range.max_qual.level;
		res.maxquality.qual = (quint8) range.max_qual.qual;
		res.maxquality.noise = (quint8) range.max_qual.noise;
		res.maxquality.updated = (quint8) range.max_qual.updated;
		qDebug() << "RANGE: " << res.maxquality.level  << res.maxquality.qual << res.maxquality.noise << res.maxquality.updated;
	}
	else {
		res.maxquality.level = 0;
		res.maxquality.qual = 0;
		res.maxquality.noise = 0;
		res.maxquality.updated = 0;
		qDebug() << "Range information are not available";
	}
	if ( (hasRange) && (range.we_version_compiled > 11) ) {
		struct iwreq wrq;
		memset(&wrq,0,sizeof(struct iwreq));
		wrq.u.data.pointer = (caddr_t) &stats;
		wrq.u.data.length = sizeof(struct iw_statistics);
		wrq.u.data.flags = 1; // Clear updated flag
		strncpy(wrq.ifr_name, m_ifname.toAscii().data(), IFNAMSIZ);
		
		qDebug() << "Getting wireless stats";
		if(iw_get_ext(m_wextFd, m_ifname.toAscii().data(), SIOCGIWSTATS, &wrq) < 0) {
			qWarning() << tr("Error occured while fetching wireless info: ") << strerror(errno);
		}
		else { //Stats fetched
			qDebug() << "Stats fetched";
			res.quality.level = (quint8) stats.qual.level;
			res.quality.qual = (quint8) stats.qual.qual;
			res.quality.noise = (quint8) stats.qual.noise;
			res.quality.updated = (quint8) stats.qual.updated;
			qDebug() << "STATS: " << res.quality.level << res.quality.qual << res.quality.noise << res.quality.updated;
			m_sq = convertValues(res);
			qDebug() << "Emittig m_signalQualityUpdated()";
			if (m_sqPollrate < 1000) {
				setSignalQualityPollRate(10000);
				emit message(tr("Auto-resetting timer to 10 seconds"));
			}
			emit signalQualityUpdated(m_sq);
		}
	}
	else if (range.we_version_compiled <= 11) {
		emit message(tr("Cannot fetch wireless information as your wireless extension is too old"));
		emit message(tr("Think about updating your kernel (it's way too old)"));
	}
	else {
		qDebug() << "Error while trying to fetch wireless information" << strerror(errno);
		qDebug() << "Wireless Extension socket file descriptor was: " << m_wextFd;
	}
}