summaryrefslogtreecommitdiffstats
path: root/src/plugins/mediaservices/qt7
diff options
context:
space:
mode:
authorJustin McPherson <justin.mcpherson@nokia.com>2010-02-25 00:07:05 (GMT)
committerJustin McPherson <justin.mcpherson@nokia.com>2010-02-25 00:22:13 (GMT)
commite9f3edcb0a0223b90606108993999ad3cb37af9f (patch)
tree6f912f4631bccc8d30b9a81a452088881b11afea /src/plugins/mediaservices/qt7
parentef30a6f336d55c813423bf139d8363f50181179f (diff)
downloadQt-e9f3edcb0a0223b90606108993999ad3cb37af9f.zip
Qt-e9f3edcb0a0223b90606108993999ad3cb37af9f.tar.gz
Qt-e9f3edcb0a0223b90606108993999ad3cb37af9f.tar.bz2
QT7; Add support for setting cookies when loading a movie.
Reviewed-by: Dmytro Poplavskiy
Diffstat (limited to 'src/plugins/mediaservices/qt7')
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm
index 3f198b9..28e220c 100644
--- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm
+++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm
@@ -48,10 +48,13 @@
#include "qt7playercontrol.h"
#include "qt7videooutputcontrol.h"
+#include <QtNetwork/qnetworkcookie.h>
#include <QtMultimedia/qmediaplaylistnavigator.h>
#include <CoreFoundation/CoreFoundation.h>
+#include <Foundation/Foundation.h>
+#include <QtCore/qdatetime.h>
#include <QtCore/qurl.h>
#include <QtCore/qdebug.h>
@@ -365,17 +368,37 @@ void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream)
m_mediaStream = stream;
m_mediaStatus = QMediaPlayer::NoMedia;
- QUrl url;
+ QNetworkRequest request;
if (!content.isNull())
- url = content.canonicalUrl();
+ request = content.canonicalResource().request();
else
return;
-// qDebug() << "Open media" << url;
+ QVariant cookies = request.header(QNetworkRequest::CookieHeader);
+ if (cookies.isValid()) {
+ NSHTTPCookieStorage *store = [NSHTTPCookieStorage sharedHTTPCookieStorage];
+ QList<QNetworkCookie> cookieList = cookies.value<QList<QNetworkCookie> >();
+
+ foreach (const QNetworkCookie &requestCookie, cookieList) {
+ NSMutableDictionary *p = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ (NSString*)qString2CFStringRef(requestCookie.name()), NSHTTPCookieName,
+ (NSString*)qString2CFStringRef(requestCookie.value()), NSHTTPCookieValue,
+ (NSString*)qString2CFStringRef(requestCookie.domain()), NSHTTPCookieDomain,
+ (NSString*)qString2CFStringRef(requestCookie.path()), NSHTTPCookiePath,
+ nil
+ ];
+ if (requestCookie.isSessionCookie())
+ [p setObject:[NSString stringWithUTF8String:"TRUE"] forKey:NSHTTPCookieDiscard];
+ else
+ [p setObject:[NSDate dateWithTimeIntervalSince1970:requestCookie.expirationDate().toTime_t()] forKey:NSHTTPCookieExpires];
+
+ [store setCookie:[NSHTTPCookie cookieWithProperties:p]];
+ }
+ }
NSError *err = 0;
- NSString *urlString = (NSString *)qString2CFStringRef(url.toString());
+ NSString *urlString = (NSString *)qString2CFStringRef(request.url().toString());
NSDictionary *attr = [NSDictionary dictionaryWithObjectsAndKeys:
[NSURL URLWithString:urlString], QTMovieURLAttribute,