void LocationManager::goTo(QString destination) { if (destination.startsWith("@")) { // remove '@' and go to user goToUser(destination.remove(0, 1)); return; } if (destination.startsWith("#")) { // remove '#' and go to named place goToPlace(destination.remove(0, 1)); return; } // go to coordinate destination or to Username if (!goToDestination(destination)) { destination = QString(QUrl::toPercentEncoding(destination)); JSONCallbackParameters callbackParams; callbackParams.jsonCallbackReceiver = this; callbackParams.jsonCallbackMethod = "goToAddressFromResponse"; AccountManager::getInstance().authenticatedRequest(GET_ADDRESSES.arg(destination), QNetworkAccessManager::GetOperation, callbackParams); } }
bool AddressManager::handleUsername(const QString& lookupString) { const QString USERNAME_REGEX_STRING = "^@(\\S+)"; QRegExp usernameRegex(USERNAME_REGEX_STRING); if (usernameRegex.indexIn(lookupString) != -1) { goToUser(usernameRegex.cap(1)); return true; } return false; }
void LocationManager::goTo(QString destination) { const QString USER_DESTINATION_TYPE = "user"; const QString PLACE_DESTINATION_TYPE = "place"; const QString OTHER_DESTINATION_TYPE = "coordinate_or_username"; if (destination.startsWith("@")) { // remove '@' and go to user QString destinationUser = destination.remove(0, 1); UserActivityLogger::getInstance().wentTo(USER_DESTINATION_TYPE, destinationUser); goToUser(destinationUser); return; } if (destination.startsWith("#")) { // remove '#' and go to named place QString destinationPlace = destination.remove(0, 1); UserActivityLogger::getInstance().wentTo(PLACE_DESTINATION_TYPE, destinationPlace); goToPlace(destinationPlace); return; } // go to coordinate destination or to Username if (!goToDestination(destination)) { destination = QString(QUrl::toPercentEncoding(destination)); UserActivityLogger::getInstance().wentTo(OTHER_DESTINATION_TYPE, destination); JSONCallbackParameters callbackParams; callbackParams.jsonCallbackReceiver = this; callbackParams.jsonCallbackMethod = "goToAddressFromResponse"; callbackParams.errorCallbackReceiver = this; callbackParams.errorCallbackMethod = "handleAddressLookupError"; AccountManager::getInstance().authenticatedRequest(GET_ADDRESSES.arg(destination), QNetworkAccessManager::GetOperation, callbackParams); } }