Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
631133d9
Commit
631133d9
authored
Jan 03, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backup of the youtube button bugfix DO NOT ERASE THE COMMENTS
parent
ff6fbd52
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
589 additions
and
26 deletions
+589
-26
UBOEmbedParser.cpp
src/web/UBOEmbedParser.cpp
+258
-0
UBOEmbedParser.h
src/web/UBOEmbedParser.h
+93
-0
UBWebController.cpp
src/web/UBWebController.cpp
+130
-6
UBWebController.h
src/web/UBWebController.h
+13
-16
UBOEmbedParser.cpp
src/web/browser/UBOEmbedParser.cpp
+91
-0
web.pri
src/web/web.pri
+4
-4
No files found.
src/web/UBOEmbedParser.cpp
0 → 100644
View file @
631133d9
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QRegExp>
#include <QStringList>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNode>
#include <QScriptValue>
#include <QScriptEngine>
#include <QDebug>
#include "UBOEmbedParser.h"
UBOEmbedParser
::
UBOEmbedParser
(
QObject
*
parent
,
const
char
*
name
)
{
setObjectName
(
name
);
mParsedTitles
.
clear
();
connect
(
this
,
SIGNAL
(
parseContent
(
QString
)),
this
,
SLOT
(
onParseContent
(
QString
)));
}
UBOEmbedParser
::~
UBOEmbedParser
()
{
}
void
UBOEmbedParser
::
setNetworkAccessManager
(
QNetworkAccessManager
*
nam
)
{
mpNam
=
nam
;
connect
(
mpNam
,
SIGNAL
(
finished
(
QNetworkReply
*
)),
this
,
SLOT
(
onFinished
(
QNetworkReply
*
)));
}
void
UBOEmbedParser
::
parse
(
const
QString
&
html
)
{
mContents
.
clear
();
QString
query
=
"<link([^>]*)>"
;
QRegExp
exp
(
query
);
QStringList
results
;
int
count
=
0
;
int
pos
=
0
;
while
((
pos
=
exp
.
indexIn
(
html
,
pos
))
!=
-
1
)
{
++
count
;
pos
+=
exp
.
matchedLength
();
QStringList
res
=
exp
.
capturedTexts
();
if
(
""
!=
res
.
at
(
1
)){
results
<<
res
.
at
(
1
);
}
}
QVector
<
QString
>
oembedUrls
;
if
(
2
<=
results
.
size
()){
for
(
int
i
=
1
;
i
<
results
.
size
();
i
++
){
if
(
""
!=
results
.
at
(
i
)){
QString
qsNode
=
QString
(
"<link%0>"
).
arg
(
results
.
at
(
i
));
QDomDocument
domDoc
;
domDoc
.
setContent
(
qsNode
);
QDomNode
linkNode
=
domDoc
.
documentElement
();
// At this point, we have a node that is the <link> element. Now we have to parse its attributes
// in order to check if it is a oEmbed node or not
QDomAttr
typeAttribute
=
linkNode
.
toElement
().
attributeNode
(
"type"
);
if
(
typeAttribute
.
value
().
contains
(
"oembed"
)){
// The node is an oembed one! We have to get the url and the type of oembed encoding
QDomAttr
hrefAttribute
=
linkNode
.
toElement
().
attributeNode
(
"href"
);
QString
url
=
hrefAttribute
.
value
();
oembedUrls
.
append
(
url
);
}
}
}
}
mPending
=
oembedUrls
.
size
();
if
(
0
==
mPending
){
emit
oembedParsed
(
mContents
);
}
else
{
// Here we start the parsing (finally...)!
for
(
int
i
=
0
;
i
<
oembedUrls
.
size
();
i
++
){
emit
parseContent
(
oembedUrls
.
at
(
i
));
}
}
}
/**
/brief Extract the oembed infos from the JSON
@param jsonUrl as the url of the JSON file
*/
sOEmbedContent
UBOEmbedParser
::
getJSONInfos
(
const
QString
&
json
)
{
sOEmbedContent
content
;
QScriptValue
scriptValue
;
QScriptEngine
scriptEngine
;
scriptValue
=
scriptEngine
.
evaluate
(
"("
+
json
+
")"
);
QString
providerUrl
=
scriptValue
.
property
(
"provider_url"
).
toString
();
QString
title
=
scriptValue
.
property
(
"title"
).
toString
();
QString
html
=
scriptValue
.
property
(
"html"
).
toString
();
QString
authorName
=
scriptValue
.
property
(
"author_name"
).
toString
();
int
height
=
scriptValue
.
property
(
"height"
).
toInteger
();
int
thumbnailWidth
=
scriptValue
.
property
(
"thumbnail_width"
).
toInteger
();
int
width
=
scriptValue
.
property
(
"width"
).
toInteger
();
float
version
=
scriptValue
.
property
(
"version"
).
toString
().
toFloat
();
QString
authorUrl
=
scriptValue
.
property
(
"author_url"
).
toString
();
QString
providerName
=
scriptValue
.
property
(
"provider_name"
).
toString
();
QString
thumbnailUrl
=
scriptValue
.
property
(
"thumbnail_url"
).
toString
();
QString
type
=
scriptValue
.
property
(
"type"
).
toString
();
int
thumbnailHeight
=
scriptValue
.
property
(
"thumbnail_height"
).
toInteger
();
content
.
providerUrl
=
providerUrl
;
content
.
title
=
title
;
content
.
html
=
html
;
content
.
author
=
authorName
;
content
.
height
=
height
;
content
.
thumbWidth
=
thumbnailWidth
;
content
.
width
=
width
;
content
.
version
=
version
;
content
.
authorUrl
=
authorUrl
;
content
.
providerName
=
providerName
;
content
.
thumbUrl
=
thumbnailUrl
;
content
.
type
=
type
;
content
.
thumbHeight
=
thumbnailHeight
;
if
(
"photo"
==
content
.
type
){
content
.
url
=
scriptValue
.
property
(
"url"
).
toString
();
}
else
if
(
"video"
==
content
.
type
){
QStringList
strl
=
content
.
html
.
split
(
'\"'
);
for
(
int
i
=
0
;
i
<
strl
.
size
();
i
++
){
if
(
strl
.
at
(
i
).
endsWith
(
"src="
)
&&
strl
.
size
()
>
(
i
+
1
)){
content
.
url
=
strl
.
at
(
i
+
1
);
}
}
}
return
content
;
}
/**
/brief Extract the oembed infos from the XML
@param xmlUrl as the url of the XML file
*/
sOEmbedContent
UBOEmbedParser
::
getXMLInfos
(
const
QString
&
xml
)
{
sOEmbedContent
content
;
QDomDocument
domDoc
;
domDoc
.
setContent
(
xml
);
QDomNode
oembed
=
domDoc
.
documentElement
();
QDomNodeList
children
=
oembed
.
toElement
().
childNodes
();
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++
){
QDomNode
node
=
children
.
at
(
i
);
QString
tag
=
node
.
nodeName
();
QString
value
=
node
.
toElement
().
text
();
if
(
"provider_url"
==
tag
){
content
.
providerUrl
=
value
;
}
else
if
(
"title"
==
tag
){
content
.
title
=
value
;
}
else
if
(
"html"
==
tag
){
content
.
html
=
value
;
}
else
if
(
"author_name"
==
tag
){
content
.
author
=
value
;
}
else
if
(
"height"
==
tag
){
content
.
height
=
value
.
toInt
();
}
else
if
(
"thumbnail_width"
==
tag
){
content
.
thumbWidth
=
value
.
toInt
();
}
else
if
(
"width"
==
tag
){
content
.
width
=
value
.
toInt
();
}
else
if
(
"version"
==
tag
){
content
.
version
=
value
.
toFloat
();
}
else
if
(
"author_url"
==
tag
){
content
.
authorUrl
=
value
;
}
else
if
(
"provider_name"
==
tag
){
content
.
providerName
=
value
;
}
else
if
(
"thumbnail_url"
==
tag
){
content
.
thumbUrl
=
value
;
}
else
if
(
"type"
==
tag
){
content
.
type
=
value
;
}
else
if
(
"thumbnail_height"
==
tag
){
content
.
thumbHeight
=
value
.
toInt
();
}
else
if
(
"url"
==
tag
){
content
.
url
=
value
;
// This case appears only for type = photo
}
}
if
(
"video"
==
content
.
type
){
QStringList
strl
=
content
.
html
.
split
(
'\"'
);
for
(
int
i
=
0
;
i
<
strl
.
size
();
i
++
){
if
(
strl
.
at
(
i
).
endsWith
(
"src="
)
&&
strl
.
size
()
>
(
i
+
1
)){
content
.
url
=
strl
.
at
(
i
+
1
);
}
}
}
return
content
;
}
void
UBOEmbedParser
::
onParseContent
(
QString
url
)
{
QUrl
qurl
;
qurl
.
setEncodedUrl
(
url
.
toAscii
());
QNetworkRequest
req
;
req
.
setUrl
(
qurl
);
if
(
NULL
!=
mpNam
){
mpNam
->
get
(
req
);
}
}
void
UBOEmbedParser
::
onFinished
(
QNetworkReply
*
reply
)
{
QNetworkReply
::
NetworkError
err
=
reply
->
error
();
if
(
QNetworkReply
::
NoError
==
reply
->
error
()){
QString
receivedDatas
=
reply
->
readAll
().
constData
();
sOEmbedContent
crntContent
;
// The received datas can be in two different formats: JSON or XML
if
(
receivedDatas
.
contains
(
"<oembed>"
)){
// XML !
crntContent
=
getXMLInfos
(
receivedDatas
);
}
else
if
(
receivedDatas
.
contains
(
"{
\"
provider_url"
)){
// JSON !
crntContent
=
getJSONInfos
(
receivedDatas
);
}
// As we don't want duplicates, we have to check if the content title has already
// been parsed.
if
(
""
!=
crntContent
.
title
&&
!
mParsedTitles
.
contains
(
crntContent
.
title
)){
mParsedTitles
<<
crntContent
.
title
;
mContents
<<
crntContent
;
}
}
else
{
// We decided to not handle the error case here. If there is a problem with
// getting the oembed content information, we just don't handle it: the content
// will not be available for importation.
}
// Decrement the number of content to analyze
mPending
--
;
if
(
0
==
mPending
){
// All the oembed contents have been parsed. We notify it!
emit
oembedParsed
(
mContents
);
}
}
src/web/UBOEmbedParser.h
0 → 100644
View file @
631133d9
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBOEMBEDPARSER_H
#define UBOEMBEDPARSER_H
#include <QObject>
#include <QVector>
#include <QString>
#include <QUrl>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QMutex>
/**********************************************************************************
----------------------------------------------------------------
Here is an example of an embed content in an XML representation
----------------------------------------------------------------
<oembed>
<provider_url>http://www.youtube.com/</provider_url>
<title>EPISODE 36 Traditional Mediums</title>
<html>
<iframe width="480" height="270" src="http://www.youtube.com/embed/C3lApsNmdwM?fs=1&feature=oembed" frameborder="0" allowfullscreen></iframe>
</html>
<author_name>FZDSCHOOL</author_name>
<height>270</height>
<thumbnail_width>480</thumbnail_width>
<width>480</width>
<version>1.0</version>
<author_url>http://www.youtube.com/user/FZDSCHOOL</author_url>
<provider_name>YouTube</provider_name>
<thumbnail_url>http://i4.ytimg.com/vi/C3lApsNmdwM/hqdefault.jpg</thumbnail_url>
<type>video</type>
<thumbnail_height>360</thumbnail_height>
</oembed>
***********************************************************************************/
typedef
struct
{
QString
providerUrl
;
QString
title
;
QString
author
;
int
height
;
int
width
;
int
thumbWidth
;
float
version
;
QString
authorUrl
;
QString
providerName
;
QString
thumbUrl
;
QString
type
;
QString
thumbHeight
;
QString
html
;
QString
url
;
}
sOEmbedContent
;
class
UBOEmbedParser
:
public
QObject
{
Q_OBJECT
public
:
UBOEmbedParser
(
QObject
*
parent
=
0
,
const
char
*
name
=
"UBOEmbedParser"
);
~
UBOEmbedParser
();
void
parse
(
const
QString
&
html
);
void
setNetworkAccessManager
(
QNetworkAccessManager
*
nam
);
signals
:
void
parseContent
(
QString
url
);
void
oembedParsed
(
QVector
<
sOEmbedContent
>
contents
);
private
slots
:
void
onFinished
(
QNetworkReply
*
reply
);
void
onParseContent
(
QString
url
);
private
:
sOEmbedContent
getJSONInfos
(
const
QString
&
json
);
sOEmbedContent
getXMLInfos
(
const
QString
&
xml
);
QVector
<
sOEmbedContent
>
mContents
;
QVector
<
QString
>
mParsedTitles
;
QNetworkAccessManager
*
mpNam
;
int
mPending
;
};
#endif // UBOEMBEDPARSER_H
src/web/UBWebController.cpp
View file @
631133d9
...
...
@@ -14,6 +14,8 @@
*/
#include <QtGui>
#include <QDomDocument>
#include <QXmlQuery>
#include "frameworks/UBPlatformUtils.h"
...
...
@@ -60,7 +62,6 @@ UBWebController::UBWebController(UBMainWindow* mainWindow)
// , mKeyboardCurrentPalette(0)
,
mToolsPalettePositionned
(
false
)
,
mDownloadViewIsVisible
(
false
)
{
connect
(
mMainWindow
->
actionWebTools
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
toggleWebToolsPalette
(
bool
)));
...
...
@@ -72,11 +73,13 @@ UBWebController::UBWebController(UBMainWindow* mainWindow)
mToolsPalettePositionnedList
[
i
]
=
false
;
}
connect
(
&
mOEmbedParser
,
SIGNAL
(
oembedParsed
(
QVector
<
sOEmbedContent
>
)),
this
,
SLOT
(
onOEmbedParsed
(
QVector
<
sOEmbedContent
>
)));
// TODO : Comment the next line to continue the Youtube button bugfix
initialiazemOEmbedProviders
();
}
UBWebController
::~
UBWebController
()
{
// NOOP
...
...
@@ -93,7 +96,6 @@ void UBWebController::initialiazemOEmbedProviders()
mOEmbedProviders
<<
"metacafe.com"
;
mOEmbedProviders
<<
"qik.com"
;
mOEmbedProviders
<<
"slideshare"
;
mOEmbedProviders
<<
"5min.com"
;
mOEmbedProviders
<<
"twitpic.com"
;
mOEmbedProviders
<<
"viddler.com"
;
mOEmbedProviders
<<
"vimeo.com"
;
...
...
@@ -324,16 +326,53 @@ void UBWebController::activePageChanged()
mTrapFlashController
->
updateTrapFlashFromPage
((
*
mCurrentWebBrowser
)
->
currentTabWebView
()
->
page
()
->
currentFrame
());
}
mMainWindow
->
actionWebTrap
->
setChecked
(
false
);
QUrl
latestUrl
=
(
*
mCurrentWebBrowser
)
->
currentTabWebView
()
->
url
();
// TODO : Uncomment the next line to continue the youtube button bugfix
//UBApplication::mainWindow->actionWebOEmbed->setEnabled(hasEmbeddedContent());
// And remove this line once the previous one is uncommented
UBApplication
::
mainWindow
->
actionWebOEmbed
->
setEnabled
(
isOEmbedable
(
latestUrl
));
UBApplication
::
mainWindow
->
actionEduMedia
->
setEnabled
(
isEduMedia
(
latestUrl
));
emit
activeWebPageChanged
((
*
mCurrentWebBrowser
)
->
currentTabWebView
());
}
}
bool
UBWebController
::
hasEmbeddedContent
()
{
bool
bHasContent
=
false
;
if
(
mCurrentWebBrowser
){
QString
html
=
(
*
mCurrentWebBrowser
)
->
currentTabWebView
()
->
webPage
()
->
mainFrame
()
->
toHtml
();
// search the presence of "+oembed"
QString
query
=
"
\\
+oembed([^>]*)>"
;
QRegExp
exp
(
query
);
exp
.
indexIn
(
html
);
QStringList
results
=
exp
.
capturedTexts
();
if
(
2
<=
results
.
size
()
&&
""
!=
results
.
at
(
1
)){
// An embedded content has been found, no need to check the other ones
bHasContent
=
true
;
}
else
{
QList
<
QUrl
>
contentUrls
;
lookForEmbedContent
(
&
html
,
"embed"
,
"src"
,
&
contentUrls
);
lookForEmbedContent
(
&
html
,
"video"
,
"src"
,
&
contentUrls
);
lookForEmbedContent
(
&
html
,
"object"
,
"data"
,
&
contentUrls
);
// TODO: check the hidden iFrame
if
(
!
contentUrls
.
empty
()){
bHasContent
=
true
;
}
}
}
return
bHasContent
;
}
QPixmap
UBWebController
::
captureCurrentPage
()
{
...
...
@@ -539,9 +578,12 @@ void UBWebController::showTabAtTop(bool attop)
void
UBWebController
::
captureoEmbed
()
{
if
(
mCurrentWebBrowser
&&
(
*
mCurrentWebBrowser
)
&&
(
*
mCurrentWebBrowser
)
->
currentTabWebView
())
{
if
(
mCurrentWebBrowser
&&
(
*
mCurrentWebBrowser
)
&&
(
*
mCurrentWebBrowser
)
->
currentTabWebView
()){
// TODO : Uncomment the next lines to continue the youtube button bugfix
// getEmbeddableContent();
// And comment from here
QWebView
*
webView
=
(
*
mCurrentWebBrowser
)
->
currentTabWebView
();
QUrl
currentUrl
=
webView
->
url
();
...
...
@@ -555,9 +597,56 @@ void UBWebController::captureoEmbed()
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
}
}
// --> Until here
}
}
void
UBWebController
::
lookForEmbedContent
(
QString
*
pHtml
,
QString
tag
,
QString
attribute
,
QList
<
QUrl
>
*
pList
)
{
if
(
NULL
!=
pHtml
&&
NULL
!=
pList
){
QVector
<
QString
>
urlsFound
;
// Check for <embed> content
QRegExp
exp
(
QString
(
"<%0(.*)"
).
arg
(
tag
));
exp
.
indexIn
(
*
pHtml
);
QStringList
strl
=
exp
.
capturedTexts
();
if
(
2
<=
strl
.
size
()
&&
strl
.
at
(
1
)
!=
""
){
// Here we call this regular expression:
// src\s?=\s?['"]([^'"]*)['"]
// It says: give me all characters that are after src=" (or src = ")
QRegExp
src
(
QString
(
"%0
\\
s?=
\\
s?['
\"
]([^'
\"
]*)['
\"
]"
).
arg
(
attribute
));
for
(
int
i
=
1
;
i
<
strl
.
size
();
i
++
){
src
.
indexIn
(
strl
.
at
(
i
));
QStringList
urls
=
src
.
capturedTexts
();
if
(
2
<=
urls
.
size
()
&&
urls
.
at
(
1
)
!=
""
&&
!
urlsFound
.
contains
(
urls
.
at
(
1
))){
urlsFound
<<
urls
.
at
(
1
);
pList
->
append
(
QUrl
(
urls
.
at
(
1
)));
}
}
}
}
}
void
UBWebController
::
checkForOEmbed
(
QString
*
pHtml
)
{
mOEmbedParser
.
parse
(
*
pHtml
);
}
void
UBWebController
::
getEmbeddableContent
()
{
// Get the source code of the page
if
(
mCurrentWebBrowser
){
QNetworkAccessManager
*
pNam
=
(
*
mCurrentWebBrowser
)
->
currentTabWebView
()
->
webPage
()
->
networkAccessManager
();
if
(
NULL
!=
pNam
){
QString
html
=
(
*
mCurrentWebBrowser
)
->
currentTabWebView
()
->
webPage
()
->
mainFrame
()
->
toHtml
();
mOEmbedParser
.
setNetworkAccessManager
(
pNam
);
// First, we have to check if there is some oembed content
checkForOEmbed
(
&
html
);
// Note: The other contents will be verified once the oembed ones have been checked
}
}
}
void
UBWebController
::
captureEduMedia
()
{
...
...
@@ -718,3 +807,38 @@ void UBWebController::cut()
act
->
trigger
();
}
}
void
UBWebController
::
onOEmbedParsed
(
QVector
<
sOEmbedContent
>
contents
)
{
QList
<
QUrl
>
urls
;
foreach
(
sOEmbedContent
cnt
,
contents
){
urls
<<
QUrl
(
cnt
.
url
);
}
// TODO : Implement this
//lookForEmbedContent(&html, "embed", "src", &urls);
//lookForEmbedContent(&html, "video", "src", &contentUrls);
//lookForEmbedContent(&html, "object", "data", &contentUrls);
// TODO: check the hidden iFrame
if
(
!
urls
.
empty
()){
QUrl
contentUrl
;
// The selected content url
if
(
1
==
urls
.
size
()){
contentUrl
=
urls
.
at
(
0
);
}
else
{
// TODO : Display a dialog box asking the user which content to get and set contentUrl to the selected content
}
UBGraphicsW3CWidgetItem
*
widget
=
UBApplication
::
boardController
->
activeScene
()
->
addOEmbed
(
contentUrl
);
if
(
widget
)
{
UBApplication
::
applicationController
->
showBoard
();
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
}
}
}
src/web/UBWebController.h
View file @
631133d9
...
...
@@ -19,6 +19,7 @@
#include <QtGui>
#include <QtWebKit>
#include "web/UBOEmbedParser.h"
class
WBBrowserWindow
;
class
UBApplication
;
...
...
@@ -30,7 +31,6 @@ class WBWebView;
class
UBServerXMLHttpRequest
;
//class UBKeyboardPalette;
class
UBWebController
:
public
QObject
{
Q_OBJECT
;
...
...
@@ -88,6 +88,9 @@ class UBWebController : public QObject
void
captureEduMedia
();
bool
isOEmbedable
(
const
QUrl
&
pUrl
);
bool
hasEmbeddedContent
();
void
getEmbeddableContent
();
bool
isEduMedia
(
const
QUrl
&
pUrl
);
void
copy
();
...
...
@@ -95,41 +98,36 @@ class UBWebController : public QObject
void
cut
();
private
:
void
initialiazemOEmbedProviders
();
void
tutorialWebInstance
();
void
webBrowserInstance
();
void
paraschoolWebInstance
();
void
lookForEmbedContent
(
QString
*
pHtml
,
QString
tag
,
QString
attribute
,
QList
<
QUrl
>*
pList
);
void
checkForOEmbed
(
QString
*
pHtml
);
QStackedWidget
mStackedWidget
[
TotalNumberOfWebInstances
];
QStackedWidget
mStackedWidget
[
TotalNumberOfWebInstances
];
UBMainWindow
*
mMainWindow
;
WBBrowserWindow
*
mWebBrowserList
[
TotalNumberOfWebInstances
];
WBBrowserWindow
**
mCurrentWebBrowser
;
QWidget
*
mBrowserWidget
;
UBTrapFlashController
*
mTrapFlashController
;
UBWebToolsPalette
**
mToolsCurrentPalette
;
UBWebToolsPalette
*
mToolsPaletteList
[
TotalNumberOfWebInstances
];
// UBKeyboardPalette** mKeyboardCurrentPalette;
// UBKeyboardPalette* mKeyboardPaletteList[TotalNumberOfWebInstances];
bool
mToolsPalettePositionned
;
bool
mToolsPalettePositionnedList
[
TotalNumberOfWebInstances
];
bool
mDownloadViewIsVisible
;
QStringList
mOEmbedProviders
;
void
initialiazemOEmbedProviders
();
void
tutorialWebInstance
();
void
webBrowserInstance
();
void
paraschoolWebInstance
();
UBOEmbedParser
mOEmbedParser
;
private
slots
:
void
activePageChanged
();
void
trapFlash
();
void
toggleWebTrap
(
bool
checked
);
void
onOEmbedParsed
(
QVector
<
sOEmbedContent
>
contents
);
// void showKeyboard(bool checked);
signals
:
...
...
@@ -139,7 +137,6 @@ class UBWebController : public QObject
* @param pCapturedPixmap QPixmap corresponding to the capture.
*/
void
imageCaptured
(
const
QPixmap
&
pCapturedPixmap
,
bool
pageMode
,
const
QUrl
&
source
);
void
activeWebPageChanged
(
WBWebView
*
pWebView
);
};
...
...
src/web/browser/UBOEmbedParser.cpp
0 → 100644
View file @
631133d9
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QRegExp>
#include "UBOEmbedParser.h"
/**********************************************************************************
----------------------------------------------------------------
Here is an example of an embed content in an XML representation
----------------------------------------------------------------
<oembed>
<provider_url>http://www.youtube.com/</provider_url>
<title>EPISODE 36 Traditional Mediums</title>
<html>
<iframe width="480" height="270" src="http://www.youtube.com/embed/C3lApsNmdwM?fs=1&feature=oembed" frameborder="0" allowfullscreen></iframe>
</html>
<author_name>FZDSCHOOL</author_name>
<height>270</height>
<thumbnail_width>480</thumbnail_width>
<width>480</width>
<version>1.0</version>
<author_url>http://www.youtube.com/user/FZDSCHOOL</author_url>
<provider_name>YouTube</provider_name>
<thumbnail_url>http://i4.ytimg.com/vi/C3lApsNmdwM/hqdefault.jpg</thumbnail_url>
<type>video</type>
<thumbnail_height>360</thumbnail_height>
</oembed>
***********************************************************************************/
typedef
struct
{
QString
providerUrl
;
QString
title
;
QString
author
;
int
height
;
int
thumbWidth
;
float
version
;
QString
authorUrl
;
QString
providerName
;
QString
thumbUrl
;
QString
type
;
QString
thumbHeight
;
QString
sourceUrl
;
}
sOEmbedContent
;
UBOEmbedParser
::
UBOEmbedParser
(
QObject
*
parent
,
const
char
*
name
)
{
setObjectName
(
name
);
mParsedTitles
.
clear
();
}
UBOEmbedParser
::~
UBOEmbedParser
()
{
}
void
UBOEmbedParser
::
parse
(
const
QString
&
html
,
QList
<
QUrl
>
*
pList
)
{
// get all the oembed links and parse their informations
QString
query
=
""
;
}
/**
/brief Extract the oembed infos from the JSON
@param jsonUrl as the url of the JSON file
*/
void
UBOEmbedParser
::
getJSONInfos
(
const
QString
&
jsonUrl
)
{
}
/**
/brief Extract the oembed infos from the XML
@param xmlUrl as the url of the XML file
*/
void
UBOEmbedParser
::
getXMLInfos
(
const
QString
&
xmlUrl
)
{
}
src/web/web.pri
View file @
631133d9
...
...
@@ -26,7 +26,8 @@ HEADERS += src/web/UBWebController.h \
src/web/browser/WBUrlLineEdit.h \
src/web/browser/WBWebView.h \
src/web/browser/WBHistory.h \
src/web/browser/WBWebTrapWebView.h
src/web/browser/WBWebTrapWebView.h \
src/web/UBOEmbedParser.h
SOURCES += src/web/UBWebController.cpp \
src/web/UBTrapFlashController.cpp \
...
...
@@ -46,8 +47,7 @@ SOURCES += src/web/UBWebController.cpp \
src/web/browser/WBUrlLineEdit.cpp \
src/web/browser/WBWebView.cpp \
src/web/browser/WBHistory.cpp \
src/web/browser/WBWebTrapWebView.cpp
src/web/browser/WBWebTrapWebView.cpp \
src/web/UBOEmbedParser.cpp
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment