Merge pull request #1311 from sehraf/pr_improve_service_id

Add wrapper function to convert uint16_t service IDs to internal unsi…
This commit is contained in:
csoler 2018-08-01 20:48:55 +02:00 committed by GitHub
commit 77d5dfe18d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 5 deletions

View File

@ -1369,13 +1369,18 @@ RsServiceInfo::RsServiceInfo(
const uint16_t min_version_major,
const uint16_t min_version_minor)
:mServiceName(service_name),
mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)),
mServiceType(RsServiceInfoUIn16ToFullServiceId(service_type)),
mVersionMajor(version_major),
mVersionMinor(version_minor),
mMinVersionMajor(min_version_major),
mMinVersionMinor(min_version_minor)
{
return;
return;
}
unsigned int RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType)
{
return (((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) serviceType) << 8);
}

View File

@ -53,6 +53,8 @@ class RsServiceInfo
// minimum version can communicate with.
uint16_t mMinVersionMajor;
uint16_t mMinVersionMinor;
static unsigned int RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType);
};

View File

@ -117,7 +117,7 @@ void BandwidthStatsWidget::updateComboBoxes()
{
if(*it != ui.service_CB->itemData(indx).toInt())
{
QString sname = QString::fromUtf8(service_info_map.mServiceList[ ((*it)<<8) + 0x02000000].mServiceName.c_str()) ;
QString sname = QString::fromUtf8(service_info_map.mServiceList[RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(*it)].mServiceName.c_str()) ;
if(ui.service_CB->count() <= indx)
ui.service_CB->addItem(sname + " (0x"+QString::number(*it,16)+")",QVariant(*it)) ;

View File

@ -468,7 +468,7 @@ static QString getServiceNameString(uint16_t service_id)
if(ownServices.mServiceList.find(service_id) == ownServices.mServiceList.end())
rsServiceControl->getOwnServices(ownServices);
return QString::fromUtf8(ownServices.mServiceList[service_id].mServiceName.c_str()) ;
return QString::fromUtf8(ownServices.mServiceList[RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id)].mServiceName.c_str()) ;
}
static QString getVirtualPeerStatusString(uint8_t status)
@ -574,7 +574,7 @@ void GxsNetTunnelsDialog::updateDisplay()
for(auto it(groups.begin());it!=groups.end();++it)
{
painter.drawText(ox+4*cellx,oy+celly,tr("Service: %1 (%2) - Group ID: %3,\t policy: %4, \tstatus: %5, \tlast contact: %6")
.arg(QString::number(it->second.service_id))
.arg("0x" + QString::number(it->second.service_id, 16))
.arg(getServiceNameString(it->second.service_id))
.arg(QString::fromStdString(it->first.toStdString()))
.arg(getGroupPolicyString(it->second.group_policy))