void MainPage::messageRead(const QNdefMessage contents) { bool success; QNdefMessage in; QString name; if (contents.length() == 0) { success = false; goto done; } /* TODO: UI notification if conversion drops data? */ /* Convert incoming data so we don't have to deal with this mess later on -- Qt API could have had some consideration for this */ if (VCardNdefRecord::hasSupportedMimeType(contents[0]) && contents.length() == 1) { in << VCardNdefRecord::fromSupportedMimeType(contents[0]); } else if (BtNdefRecord::hasSupportedMimeType(contents[0]) && contents.length() == 1) { in << BtNdefRecord::fromSupportedMimeType(contents[0]); } else if (contents[0].isRecordType<NfcHandoverSelectNdefRecord>() && contents.length() == 2 && BtNdefRecord::hasSupportedMimeType(contents[1])) { in << contents[0]; in << BtNdefRecord::fromSupportedMimeType(contents[1]); } else { in = contents; } mDebug(__func__) << "Saving temp"; name = "Harvested tag"; success = TagStorage::storage()->update(TagStorage::TEMPORARY_TAG, name, in); done: if (success == false) { MMessageBox *box = new MMessageBox(tr("Cannot store the tag. ")); box->appear(MSceneWindow::DestroyWhenDismissed); } else { mDebug(__func__) << "Editing temp"; editTag(TagStorage::TEMPORARY_TAG); } }