void InjectedBundle::queueLoadHTMLString(WKStringRef content, WKStringRef baseURL, WKStringRef unreachableURL) { m_useWorkQueue = true; WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueLoadHTMLString")); WKRetainPtr<WKMutableDictionaryRef> loadData(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> contentKey(AdoptWK, WKStringCreateWithUTF8CString("content")); WKDictionarySetItem(loadData.get(), contentKey.get(), content); if (baseURL) { WKRetainPtr<WKStringRef> baseURLKey(AdoptWK, WKStringCreateWithUTF8CString("baseURL")); WKDictionarySetItem(loadData.get(), baseURLKey.get(), baseURL); } if (unreachableURL) { WKRetainPtr<WKStringRef> unreachableURLKey(AdoptWK, WKStringCreateWithUTF8CString("unreachableURL")); WKDictionarySetItem(loadData.get(), unreachableURLKey.get(), unreachableURL); } WKBundlePostMessage(m_bundle, messageName.get(), loadData.get()); }
void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody) { if (WKStringIsEqualToUTF8CString(messageName, "Error")) { // Set all states to true to stop spinning the runloop. m_gotInitialResponse = true; m_gotFinalMessage = true; m_error = true; m_errorMessage = "FAIL\n"; TestController::shared().notifyDone(); return; } if (WKStringIsEqualToUTF8CString(messageName, "Ack")) { ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); WKStringRef messageBodyString = static_cast<WKStringRef>(messageBody); if (WKStringIsEqualToUTF8CString(messageBodyString, "BeginTest")) { m_gotInitialResponse = true; TestController::shared().notifyDone(); return; } ASSERT_NOT_REACHED(); } if (WKStringIsEqualToUTF8CString(messageName, "Done")) { ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); WKRetainPtr<WKStringRef> textOutputKey(AdoptWK, WKStringCreateWithUTF8CString("TextOutput")); m_textOutput = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, textOutputKey.get())); WKRetainPtr<WKStringRef> pixelResultKey = adoptWK(WKStringCreateWithUTF8CString("PixelResult")); m_pixelResult = static_cast<WKImageRef>(WKDictionaryGetItemForKey(messageBodyDictionary, pixelResultKey.get())); ASSERT(!m_pixelResult || m_dumpPixels); WKRetainPtr<WKStringRef> repaintRectsKey = adoptWK(WKStringCreateWithUTF8CString("RepaintRects")); m_repaintRects = static_cast<WKArrayRef>(WKDictionaryGetItemForKey(messageBodyDictionary, repaintRectsKey.get())); m_gotFinalMessage = true; TestController::shared().notifyDone(); return; } if (WKStringIsEqualToUTF8CString(messageName, "BeforeUnloadReturnValue")) { ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID()); WKBooleanRef beforeUnloadReturnValue = static_cast<WKBooleanRef>(messageBody); TestController::shared().setBeforeUnloadReturnValue(WKBooleanGetValue(beforeUnloadReturnValue)); return; } if (WKStringIsEqualToUTF8CString(messageName, "AddChromeInputField")) { TestController::shared().mainWebView()->addChromeInputField(); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallAddChromeInputFieldCallback")); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); return; } if (WKStringIsEqualToUTF8CString(messageName, "RemoveChromeInputField")) { TestController::shared().mainWebView()->removeChromeInputField(); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallRemoveChromeInputFieldCallback")); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); return; } if (WKStringIsEqualToUTF8CString(messageName, "FocusWebView")) { TestController::shared().mainWebView()->makeWebViewFirstResponder(); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallFocusWebViewCallback")); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); return; } if (WKStringIsEqualToUTF8CString(messageName, "SetBackingScaleFactor")) { ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID()); double backingScaleFactor = WKDoubleGetValue(static_cast<WKDoubleRef>(messageBody)); WKPageSetCustomBackingScaleFactor(TestController::shared().mainWebView()->page(), backingScaleFactor); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallSetBackingScaleFactorCallback")); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); return; } if (WKStringIsEqualToUTF8CString(messageName, "SimulateWebNotificationClick")) { ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID()); uint64_t notificationID = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody)); TestController::shared().simulateWebNotificationClick(notificationID); return; } if (WKStringIsEqualToUTF8CString(messageName, "SetGeolocationPermission")) { ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID()); WKBooleanRef enabledWK = static_cast<WKBooleanRef>(messageBody); TestController::shared().setGeolocationPermission(WKBooleanGetValue(enabledWK)); return; } if (WKStringIsEqualToUTF8CString(messageName, "SetMockGeolocationPosition")) { ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); WKRetainPtr<WKStringRef> latitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("latitude")); WKDoubleRef latitudeWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, latitudeKeyWK.get())); double latitude = WKDoubleGetValue(latitudeWK); WKRetainPtr<WKStringRef> longitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("longitude")); WKDoubleRef longitudeWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, longitudeKeyWK.get())); double longitude = WKDoubleGetValue(longitudeWK); WKRetainPtr<WKStringRef> accuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("accuracy")); WKDoubleRef accuracyWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, accuracyKeyWK.get())); double accuracy = WKDoubleGetValue(accuracyWK); WKRetainPtr<WKStringRef> providesAltitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesAltitude")); WKBooleanRef providesAltitudeWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, providesAltitudeKeyWK.get())); bool providesAltitude = WKBooleanGetValue(providesAltitudeWK); WKRetainPtr<WKStringRef> altitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("altitude")); WKDoubleRef altitudeWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, altitudeKeyWK.get())); double altitude = WKDoubleGetValue(altitudeWK); WKRetainPtr<WKStringRef> providesAltitudeAccuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesAltitudeAccuracy")); WKBooleanRef providesAltitudeAccuracyWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, providesAltitudeAccuracyKeyWK.get())); bool providesAltitudeAccuracy = WKBooleanGetValue(providesAltitudeAccuracyWK); WKRetainPtr<WKStringRef> altitudeAccuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("altitudeAccuracy")); WKDoubleRef altitudeAccuracyWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, altitudeAccuracyKeyWK.get())); double altitudeAccuracy = WKDoubleGetValue(altitudeAccuracyWK); WKRetainPtr<WKStringRef> providesHeadingKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesHeading")); WKBooleanRef providesHeadingWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, providesHeadingKeyWK.get())); bool providesHeading = WKBooleanGetValue(providesHeadingWK); WKRetainPtr<WKStringRef> headingKeyWK(AdoptWK, WKStringCreateWithUTF8CString("heading")); WKDoubleRef headingWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, headingKeyWK.get())); double heading = WKDoubleGetValue(headingWK); WKRetainPtr<WKStringRef> providesSpeedKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesSpeed")); WKBooleanRef providesSpeedWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, providesSpeedKeyWK.get())); bool providesSpeed = WKBooleanGetValue(providesSpeedWK); WKRetainPtr<WKStringRef> speedKeyWK(AdoptWK, WKStringCreateWithUTF8CString("speed")); WKDoubleRef speedWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, speedKeyWK.get())); double speed = WKDoubleGetValue(speedWK); TestController::shared().setMockGeolocationPosition(latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed); return; } if (WKStringIsEqualToUTF8CString(messageName, "SetMockGeolocationPositionUnavailableError")) { ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); WKStringRef errorMessage = static_cast<WKStringRef>(messageBody); TestController::shared().setMockGeolocationPositionUnavailableError(errorMessage); return; } if (WKStringIsEqualToUTF8CString(messageName, "SetCustomPolicyDelegate")) { ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); WKRetainPtr<WKStringRef> enabledKeyWK(AdoptWK, WKStringCreateWithUTF8CString("enabled")); WKBooleanRef enabledWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, enabledKeyWK.get())); bool enabled = WKBooleanGetValue(enabledWK); WKRetainPtr<WKStringRef> permissiveKeyWK(AdoptWK, WKStringCreateWithUTF8CString("permissive")); WKBooleanRef permissiveWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, permissiveKeyWK.get())); bool permissive = WKBooleanGetValue(permissiveWK); TestController::shared().setCustomPolicyDelegate(enabled, permissive); return; } if (WKStringIsEqualToUTF8CString(messageName, "ProcessWorkQueue")) { if (TestController::shared().workQueueManager().processWorkQueue()) { WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("WorkQueueProcessedCallback")); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); } return; } if (WKStringIsEqualToUTF8CString(messageName, "QueueBackNavigation")) { ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID()); uint64_t stepCount = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody)); TestController::shared().workQueueManager().queueBackNavigation(stepCount); return; } if (WKStringIsEqualToUTF8CString(messageName, "QueueForwardNavigation")) { ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID()); uint64_t stepCount = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody)); TestController::shared().workQueueManager().queueForwardNavigation(stepCount); return; } if (WKStringIsEqualToUTF8CString(messageName, "QueueLoad")) { ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); WKDictionaryRef loadDataDictionary = static_cast<WKDictionaryRef>(messageBody); WKRetainPtr<WKStringRef> urlKey(AdoptWK, WKStringCreateWithUTF8CString("url")); WKStringRef urlWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(loadDataDictionary, urlKey.get())); WKRetainPtr<WKStringRef> targetKey(AdoptWK, WKStringCreateWithUTF8CString("target")); WKStringRef targetWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(loadDataDictionary, targetKey.get())); TestController::shared().workQueueManager().queueLoad(toWTFString(urlWK), toWTFString(targetWK)); return; } if (WKStringIsEqualToUTF8CString(messageName, "QueueLoadHTMLString")) { ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); WKDictionaryRef loadDataDictionary = static_cast<WKDictionaryRef>(messageBody); WKRetainPtr<WKStringRef> contentKey(AdoptWK, WKStringCreateWithUTF8CString("content")); WKStringRef contentWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(loadDataDictionary, contentKey.get())); WKRetainPtr<WKStringRef> baseURLKey(AdoptWK, WKStringCreateWithUTF8CString("baseURL")); WKStringRef baseURLWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(loadDataDictionary, baseURLKey.get())); WKRetainPtr<WKStringRef> unreachableURLKey(AdoptWK, WKStringCreateWithUTF8CString("unreachableURL")); WKStringRef unreachableURLWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(loadDataDictionary, unreachableURLKey.get())); TestController::shared().workQueueManager().queueLoadHTMLString(toWTFString(contentWK), baseURLWK ? toWTFString(baseURLWK) : String(), unreachableURLWK ? toWTFString(unreachableURLWK) : String()); return; } if (WKStringIsEqualToUTF8CString(messageName, "QueueReload")) { TestController::shared().workQueueManager().queueReload(); return; } if (WKStringIsEqualToUTF8CString(messageName, "QueueLoadingScript")) { ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); WKStringRef script = static_cast<WKStringRef>(messageBody); TestController::shared().workQueueManager().queueLoadingScript(toWTFString(script)); return; } if (WKStringIsEqualToUTF8CString(messageName, "QueueNonLoadingScript")) { ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); WKStringRef script = static_cast<WKStringRef>(messageBody); TestController::shared().workQueueManager().queueNonLoadingScript(toWTFString(script)); return; } ASSERT_NOT_REACHED(); }
EmailStandardFolderMessageSet::EmailStandardFolderMessageSet(QMailMessageSetContainer *container, QMailFolder::StandardFolder folderType, const QString &name) : QMailFilterMessageSet(container, contentKey(folderType), name), _type(folderType) { }
QMailMessageKey InboxMessageSet::messageKey() const { return contentKey(); }
QMailMessageKey EmailAccountMessageSet::messageKey() const { return contentKey(accountId()); }
QMailMessageKey EmailFolderMessageSet::descendantsMessageKey() const { return contentKey(folderId(), true); }
QMailMessageKey EmailFolderMessageSet::messageKey() const { return contentKey(folderId(), false); }
UtlBoolean SipSubscriptionMgr::endSubscription(const UtlString& dialogHandle) { UtlBoolean subscriptionFound = FALSE; lock(); SubscriptionServerState* state = (SubscriptionServerState*) mSubscriptionStatesByDialogHandle.find(&dialogHandle); if (state) { SubscriptionServerStateIndex* stateIndex = NULL; UtlString contentKey(state->mResourceId); contentKey.append(state->mEventTypeKey); UtlHashBagIterator iterator(mSubscriptionStateResourceIndex, &contentKey); while((stateIndex = (SubscriptionServerStateIndex*) iterator())) { if(stateIndex->mpState == state) { mSubscriptionStatesByDialogHandle.removeReference(state); mSubscriptionStateResourceIndex.removeReference(stateIndex); if (OsSysLog::willLog(FAC_SIP, PRI_DEBUG)) { UtlString requestContact; state->mpLastSubscribeRequest->getContactField(0, requestContact); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscriptionMgr::endSubscription delete subscription for dialog handle '%s', key '%s', contact '%s', mExpirationDate %ld", state->data(), stateIndex->data(), requestContact.data(), state->mExpirationDate); } delete state; delete stateIndex; subscriptionFound = TRUE; break; } } // Could not find the state index that corresponds to the state // Should not happen, there should always be one of each if (!subscriptionFound) { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscriptionMgr::endSubscription Could not find subscription in mSubscriptionStateResourceIndex for content key '%s', dialog handle '%s'", contentKey.data(), dialogHandle.data()); } } else { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscriptionMgr::endSubscription Could not find subscription in mSubscriptionStatesByDialogHandle for dialog handle '%s'", dialogHandle.data()); } unlock(); // Remove the dialog mDialogMgr.deleteDialog(dialogHandle); return(subscriptionFound); }
UtlBoolean SipSubscriptionMgr::createNotifiesDialogInfo(const char* resourceId, const char* eventTypeKey, int& numNotifiesCreated, UtlString**& acceptHeaderValuesArray, SipMessage**& notifyArray) { UtlString contentKey(resourceId); contentKey.append(eventTypeKey); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscriptionMgr::createNotifiesDialogInfo try to find contentKey '%s' in mSubscriptionStateResourceIndex (%zu entries)", contentKey.data(), mSubscriptionStateResourceIndex.entries()); lock(); #if 0 // Enable for very detailed logging of searching for the NOTIFY info. if (OsSysLog::willLog(FAC_SIP, PRI_DEBUG)) { UtlHashBagIterator iterator(mSubscriptionStateResourceIndex); UtlString* contentTypeIndex; while ((contentTypeIndex = dynamic_cast <SubscriptionServerStateIndex*> (iterator()))) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscriptionMgr::createNotifiesDialogInfo element '%s'", contentTypeIndex->data()); } } #endif // 0 UtlHashBagIterator iterator(mSubscriptionStateResourceIndex, &contentKey); int count = 0; int index = 0; acceptHeaderValuesArray = NULL; notifyArray = NULL; while (iterator()) { count++; } if (count > 0) { SubscriptionServerStateIndex* subscriptionIndex = NULL; acceptHeaderValuesArray = new UtlString*[count]; notifyArray = new SipMessage*[count]; iterator.reset(); long now = OsDateTime::getSecsSinceEpoch(); while ((subscriptionIndex = (SubscriptionServerStateIndex*)iterator())) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscriptionMgr::createNotifiesDialogInfo now %ld, mExpirationDate %ld", now, subscriptionIndex->mpState->mExpirationDate); // Should not happen, the container is supposed to be locked if(index >= count) { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscriptionMgr::createNotifiesDialogInfo iterator elements count changed from: %d to %d while locked", count, index); } // Should not happen, the index should be created and // deleted with the state else if (subscriptionIndex->mpState == NULL) { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscriptionMgr::createNotifiesDialogInfo SubscriptionServerStateIndex with NULL mpState"); } // If not expired yet else if(subscriptionIndex->mpState->mExpirationDate >= now) { // Get the accept value. acceptHeaderValuesArray[index] = new UtlString(subscriptionIndex->mpState->mAcceptHeaderValue); // Create the NOTIFY message. notifyArray[index] = new SipMessage; mDialogMgr.setNextLocalTransactionInfo(*(notifyArray[index]), SIP_NOTIFY_METHOD, // This is a SubscriptionServerStateIndex, // whose superclass UtlString contains // the dialog handle for the subscription. static_cast <const UtlString> (*(subscriptionIndex->mpState))); // Set the event header, if we know what it is. UtlString eventHeader; if(subscriptionIndex->mpState->mpLastSubscribeRequest) { subscriptionIndex->mpState->mpLastSubscribeRequest->getEventField(eventHeader); } notifyArray[index]->setEventField(eventHeader); // Set the subscription-state header. char buffer[30]; sprintf(buffer, "active;expires=%ld", subscriptionIndex->mpState->mExpirationDate - now); notifyArray[index]->setHeaderValue(SIP_SUBSCRIPTION_STATE_FIELD, buffer, 0); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscriptionMgr::createNotifiesDialogInfo index %d, mAcceptHeaderValue '%s', getEventField '%s'", index, acceptHeaderValuesArray[index]->data(), eventHeader.data()); if (OsSysLog::willLog(FAC_SIP, PRI_DEBUG)) { UtlString s; ssize_t i; notifyArray[index]->getBytes(&s, &i); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscriptionMgr::createNotifiesDialogInfo notifyArray[%d] = '%s'", index, s.data()); } index++; } } } unlock(); numNotifiesCreated = index; return(index > 0); }
EmailActionMessageSet::EmailActionMessageSet(QMailMessageSetContainer *container, const QString &name) : QMailFilterMessageSet(container, contentKey(), name, false) { }
QMailMessageKey ActionFolderMessageSet::messageKey() const { return contentKey(folderId()); }