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
ac754bb6
Commit
ac754bb6
authored
Sep 24, 2012
by
Aleksei Kanash
Browse files
Options
Browse Files
Download
Plain Diff
Last changes for download_thread
parents
6b1df01c
9b1d2932
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
219 additions
and
85 deletions
+219
-85
UBLibraryAPI.cpp
src/api/UBLibraryAPI.cpp
+1
-1
UBWidgetUniboardAPI.cpp
src/api/UBWidgetUniboardAPI.cpp
+2
-2
UBBoardController.cpp
src/board/UBBoardController.cpp
+87
-54
UBBoardController.h
src/board/UBBoardController.h
+4
-4
UBFeaturesController.cpp
src/board/UBFeaturesController.cpp
+1
-1
UBDownloadManager.cpp
src/core/UBDownloadManager.cpp
+23
-12
UBDownloadManager.h
src/core/UBDownloadManager.h
+4
-3
UBGraphicsMediaItem.cpp
src/domain/UBGraphicsMediaItem.cpp
+7
-3
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+5
-0
UBFileSystemUtils.cpp
src/frameworks/UBFileSystemUtils.cpp
+54
-0
UBFileSystemUtils.h
src/frameworks/UBFileSystemUtils.h
+27
-1
UBFeaturesWidget.cpp
src/gui/UBFeaturesWidget.cpp
+2
-2
UBTrapFlashController.cpp
src/web/UBTrapFlashController.cpp
+1
-1
WBWebTrapWebView.cpp
src/web/browser/WBWebTrapWebView.cpp
+1
-1
No files found.
src/api/UBLibraryAPI.cpp
View file @
ac754bb6
...
...
@@ -40,7 +40,7 @@ UBLibraryAPI::~UBLibraryAPI()
void
UBLibraryAPI
::
addObject
(
QString
pUrl
,
int
width
,
int
height
,
int
x
,
int
y
,
bool
background
)
{
if
(
UBApplication
::
boardController
)
UBApplication
::
boardController
->
downloadURL
(
QUrl
(
pUrl
),
QPointF
(
x
,
y
),
QSize
(
width
,
height
),
background
);
UBApplication
::
boardController
->
downloadURL
(
QUrl
(
pUrl
),
Q
String
(),
Q
PointF
(
x
,
y
),
QSize
(
width
,
height
),
background
);
}
...
...
src/api/UBWidgetUniboardAPI.cpp
View file @
ac754bb6
...
...
@@ -201,7 +201,7 @@ void UBWidgetUniboardAPI::addObject(QString pUrl, int width, int height, int x,
if
(
UBApplication
::
boardController
->
activeScene
()
!=
mScene
)
return
;
UBApplication
::
boardController
->
downloadURL
(
QUrl
(
pUrl
),
QPointF
(
x
,
y
),
QSize
(
width
,
height
),
background
);
UBApplication
::
boardController
->
downloadURL
(
QUrl
(
pUrl
),
Q
String
(),
Q
PointF
(
x
,
y
),
QSize
(
width
,
height
),
background
);
}
...
...
@@ -506,7 +506,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QGraphicsSceneDragDropEvent *event)
sDownloadFileDesc
desc
;
desc
.
dest
=
sDownloadFileDesc
::
graphicsWidget
;
desc
.
modal
=
true
;
desc
.
u
rl
=
url
;
desc
.
srcU
rl
=
url
;
desc
.
currentSize
=
0
;
desc
.
name
=
QFileInfo
(
url
).
fileName
();
desc
.
totalSize
=
0
;
// The total size will be retrieved during the download
...
...
src/board/UBBoardController.cpp
View file @
ac754bb6
This diff is collapsed.
Click to expand it.
src/board/UBBoardController.h
View file @
ac754bb6
...
...
@@ -193,8 +193,8 @@ class UBBoardController : public UBDocumentContainer
void
firstScene
();
void
lastScene
();
void
groupButtonClicked
();
void
downloadURL
(
const
QUrl
&
url
,
const
QPointF
&
pPos
=
QPointF
(
0
.
0
,
0
.
0
),
const
QSize
&
pSize
=
QSize
(),
bool
isBackground
=
false
,
bool
internalData
=
false
);
UBItem
*
downloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pHeader
,
void
downloadURL
(
const
QUrl
&
url
,
QString
contentSourceUrl
=
QString
(),
const
QPointF
&
pPos
=
QPointF
(
0
.
0
,
0
.
0
),
const
QSize
&
pSize
=
QSize
(),
bool
isBackground
=
false
,
bool
internalData
=
false
);
UBItem
*
downloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
Q
Url
contentUrl
,
Q
String
pHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
=
false
,
bool
internalData
=
false
);
void
changeBackground
(
bool
isDark
,
bool
isCrossed
);
...
...
@@ -210,8 +210,8 @@ class UBBoardController : public UBDocumentContainer
void
setRegularPageSize
(
bool
checked
);
void
stylusToolChanged
(
int
tool
);
void
grabScene
(
const
QRectF
&
pSceneRect
);
UBGraphicsMediaItem
*
addVideo
(
const
QUrl
&
pUrl
,
bool
startPlay
,
const
QPointF
&
pos
);
UBGraphicsMediaItem
*
addAudio
(
const
QUrl
&
pUrl
,
bool
startPlay
,
const
QPointF
&
pos
);
UBGraphicsMediaItem
*
addVideo
(
const
QUrl
&
pUrl
,
bool
startPlay
,
const
QPointF
&
pos
,
bool
bUseSource
=
false
);
UBGraphicsMediaItem
*
addAudio
(
const
QUrl
&
pUrl
,
bool
startPlay
,
const
QPointF
&
pos
,
bool
bUseSource
=
false
);
UBGraphicsWidgetItem
*
addW3cWidget
(
const
QUrl
&
pUrl
,
const
QPointF
&
pos
);
void
cut
();
...
...
src/board/UBFeaturesController.cpp
View file @
ac754bb6
...
...
@@ -711,7 +711,7 @@ void UBFeaturesController::addItemToPage(const UBFeature &item)
void
UBFeaturesController
::
addItemAsBackground
(
const
UBFeature
&
item
)
{
UBApplication
::
boardController
->
downloadURL
(
item
.
getFullPath
(),
QPointF
(),
QSize
(),
true
);
UBApplication
::
boardController
->
downloadURL
(
item
.
getFullPath
(),
Q
String
(),
Q
PointF
(),
QSize
(),
true
);
}
UBFeature
UBFeaturesController
::
getDestinationFeatureForUrl
(
const
QUrl
&
url
)
...
...
src/core/UBDownloadManager.cpp
View file @
ac754bb6
...
...
@@ -17,6 +17,7 @@
#include "gui/UBMainWindow.h"
#include "board/UBBoardController.h"
#include "board/UBBoardPaletteManager.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
...
...
@@ -193,7 +194,8 @@ void UBDownloadManager::onDownloadProgress(int id, qint64 received, qint64 total
* \brief Called when the download of the given file is finished
* @param desc as the current downloaded file description
*/
void
UBDownloadManager
::
onDownloadFinished
(
int
id
,
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
)
void
UBDownloadManager
::
onDownloadFinished
(
int
id
,
bool
pSuccess
,
QUrl
sourceUrl
,
QUrl
contentUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
)
{
// Temporary data for dnd do not delete it please
Q_UNUSED
(
pPos
)
...
...
@@ -209,9 +211,9 @@ void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl
desc
.
contentTypeHeader
=
pContentTypeHeader
;
emit
downloadFinished
(
pSuccess
,
desc
,
pData
);
}
else
if
(
desc
.
modal
)
{
}
else
if
(
desc
.
dest
==
sDownloadFileDesc
::
board
)
{
// The downloaded file is modal so we must put it on the board
emit
addDownloadedFileToBoard
(
pSuccess
,
sourceUrl
,
pContentTypeHeader
,
pData
,
pPos
,
pSize
,
isBackground
);
emit
addDownloadedFileToBoard
(
pSuccess
,
sourceUrl
,
contentUrl
,
pContentTypeHeader
,
pData
,
pPos
,
pSize
,
isBackground
);
}
else
{
...
...
@@ -302,15 +304,24 @@ void UBDownloadManager::updateFileCurrentSize(int id, qint64 received, qint64 to
*/
void
UBDownloadManager
::
startFileDownload
(
sDownloadFileDesc
desc
)
{
if
(
desc
.
srcUrl
.
startsWith
(
"file://"
)
||
desc
.
srcUrl
.
startsWith
(
"/"
))
{
UBAsyncLocalFileDownloader
*
cpHelper
=
new
UBAsyncLocalFileDownloader
(
desc
,
this
);
connect
(
cpHelper
,
SIGNAL
(
signal_asyncCopyFinished
(
int
,
bool
,
QUrl
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)),
this
,
SLOT
(
onDownloadFinished
(
int
,
bool
,
QUrl
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)));
cpHelper
->
download
();
}
else
{
UBDownloadHttpFile
*
http
=
new
UBDownloadHttpFile
(
desc
.
id
,
this
);
connect
(
http
,
SIGNAL
(
downloadProgress
(
int
,
qint64
,
qint64
)),
this
,
SLOT
(
onDownloadProgress
(
int
,
qint64
,
qint64
)));
connect
(
http
,
SIGNAL
(
downloadFinished
(
int
,
bool
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)),
this
,
SLOT
(
onDownloadFinished
(
int
,
bool
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)));
//the desc.u
rl is encoded. So we have to decode it before.
//the desc.srcU
rl is encoded. So we have to decode it before.
QUrl
url
;
url
.
setEncodedUrl
(
desc
.
u
rl
.
toUtf8
());
url
.
setEncodedUrl
(
desc
.
srcU
rl
.
toUtf8
());
// We send here the request and store its reply in order to be able to cancel it if needed
mReplies
[
desc
.
id
]
=
http
->
get
(
url
,
desc
.
pos
,
desc
.
size
,
desc
.
isBackground
);
}
}
/**
...
...
src/core/UBDownloadManager.h
View file @
ac754bb6
...
...
@@ -52,7 +52,8 @@ struct sDownloadFileDesc
int
id
;
int
totalSize
;
int
currentSize
;
QString
url
;
QString
srcUrl
;
QString
originalSrcUrl
;
QString
contentTypeHeader
;
bool
modal
;
QPointF
pos
;
// For board drop only
...
...
@@ -108,7 +109,7 @@ signals:
void
downloadFinished
(
bool
pSuccess
,
int
id
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
);
void
downloadFinished
(
bool
pSuccess
,
sDownloadFileDesc
desc
,
QByteArray
pData
);
void
downloadModalFinished
();
void
addDownloadedFileToBoard
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
void
addDownloadedFileToBoard
(
bool
pSuccess
,
QUrl
sourceUrl
,
Q
Url
contentUrl
,
Q
String
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
void
addDownloadedFileToLibrary
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
);
void
cancelAllDownloads
();
void
allDownloadsFinished
();
...
...
@@ -116,7 +117,7 @@ signals:
private
slots
:
void
onUpdateDownloadLists
();
void
onDownloadProgress
(
int
id
,
qint64
received
,
qint64
total
);
void
onDownloadFinished
(
int
id
,
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
void
onDownloadFinished
(
int
id
,
bool
pSuccess
,
QUrl
sourceUrl
,
Q
Url
contentUrl
,
Q
String
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
void
onDownloadError
(
int
id
);
private
:
...
...
src/domain/UBGraphicsMediaItem.cpp
View file @
ac754bb6
...
...
@@ -73,7 +73,11 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mMediaObject
=
new
Phonon
::
MediaObject
(
this
);
if
(
pMediaFileUrl
.
toLocalFile
().
contains
(
"videos"
))
QString
mediaPath
=
pMediaFileUrl
.
toString
();
if
(
""
==
mediaPath
)
mediaPath
=
pMediaFileUrl
.
toLocalFile
();
if
(
mediaPath
.
toLower
().
contains
(
"videos"
))
{
mMediaType
=
mediaType_Video
;
...
...
@@ -91,7 +95,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
haveLinkedImage
=
true
;
}
else
if
(
pMediaFileUrl
.
toLocalFile
().
contains
(
"audios"
))
if
(
mediaPath
.
toLower
().
contains
(
"audios"
))
{
mMediaType
=
mediaType_Audio
;
mAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
MusicCategory
,
this
);
...
...
@@ -191,7 +195,7 @@ void UBGraphicsMediaItem::setSourceUrl(const QUrl &pSourceUrl)
UBAudioPresentationWidget
*
pAudioWidget
=
dynamic_cast
<
UBAudioPresentationWidget
*>
(
mAudioWidget
);
if
(
pAudioWidget
)
{
pAudioWidget
->
setTitle
(
UBFileSystemUtils
::
lastPathComponent
(
pSourceUrl
.
to
String
()));
pAudioWidget
->
setTitle
(
UBFileSystemUtils
::
lastPathComponent
(
pSourceUrl
.
to
LocalFile
()));
}
UBItem
::
setSourceUrl
(
pSourceUrl
);
...
...
src/domain/UBGraphicsScene.cpp
View file @
ac754bb6
...
...
@@ -1217,6 +1217,11 @@ void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem)
}
UBGraphicsMediaItem
*
UBGraphicsScene
::
addMedia
(
const
QUrl
&
pMediaFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
)
{
qDebug
()
<<
pMediaFileUrl
.
toLocalFile
();
if
(
!
QFile
::
exists
(
pMediaFileUrl
.
toLocalFile
()))
if
(
!
QFile
::
exists
(
pMediaFileUrl
.
toString
()))
return
NULL
;
UBGraphicsMediaItem
*
mediaItem
=
new
UBGraphicsMediaItem
(
pMediaFileUrl
);
if
(
mediaItem
){
connect
(
UBApplication
::
boardController
,
SIGNAL
(
activeSceneChanged
()),
mediaItem
,
SLOT
(
activeSceneChanged
()));
...
...
src/frameworks/UBFileSystemUtils.cpp
View file @
ac754bb6
...
...
@@ -22,6 +22,8 @@
#include "board/UBBoardController.h"
#include "document/UBDocumentContainer.h"
#include "core/UBPersistenceManager.h"
#include "globals/UBGlobals.h"
THIRD_PARTY_WARNINGS_DISABLE
...
...
@@ -856,3 +858,55 @@ QString UBFileSystemUtils::readTextFile(QString path)
return
""
;
}
UBAsyncLocalFileDownloader
::
UBAsyncLocalFileDownloader
(
sDownloadFileDesc
desc
,
QObject
*
parent
)
:
QThread
(
parent
)
,
mDesc
(
desc
)
{
}
void
UBAsyncLocalFileDownloader
::
download
()
{
if
(
!
QFile
::
exists
(
QUrl
(
mDesc
.
srcUrl
).
toLocalFile
()))
{
qDebug
()
<<
"file"
<<
mDesc
.
srcUrl
<<
"does not present in fs"
;
return
;
}
start
();
}
void
UBAsyncLocalFileDownloader
::
run
()
{
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
mDesc
.
srcUrl
);
int
position
=
mimeType
.
indexOf
(
";"
);
if
(
position
!=
-
1
)
mimeType
=
mimeType
.
left
(
position
);
UBMimeType
::
Enum
itemMimeType
=
UBFileSystemUtils
::
mimeTypeFromString
(
mimeType
);
QString
destDirectory
;
if
(
UBMimeType
::
Video
==
itemMimeType
)
destDirectory
=
UBPersistenceManager
::
videoDirectory
;
else
if
(
UBMimeType
::
Audio
==
itemMimeType
)
destDirectory
=
UBPersistenceManager
::
audioDirectory
;
QString
uuid
=
QUuid
::
createUuid
();
UBPersistenceManager
::
persistenceManager
()
->
addFileToDocument
(
UBApplication
::
boardController
->
selectedDocument
(),
QUrl
(
mDesc
.
srcUrl
).
toLocalFile
(),
destDirectory
,
uuid
,
mTo
,
NULL
);
if
(
mDesc
.
originalSrcUrl
.
isEmpty
())
mDesc
.
originalSrcUrl
=
mDesc
.
srcUrl
;
emit
signal_asyncCopyFinished
(
mDesc
.
id
,
!
mTo
.
isEmpty
(),
QUrl
::
fromLocalFile
(
mTo
),
QUrl
::
fromLocalFile
(
mDesc
.
originalSrcUrl
),
""
,
NULL
,
mDesc
.
pos
,
mDesc
.
size
,
mDesc
.
isBackground
);
}
\ No newline at end of file
src/frameworks/UBFileSystemUtils.h
View file @
ac754bb6
...
...
@@ -17,14 +17,40 @@
#define UBFILESYSTEMUTILS_H_
#include <QtCore>
#include <QThread>
#include "core/UB.h"
#include "core/UBDownloadManager.h"
class
UBAsyncLocalFileDownloader
:
public
QThread
{
Q_OBJECT
public
:
UBAsyncLocalFileDownloader
(
sDownloadFileDesc
desc
,
QObject
*
parent
=
0
);
void
download
();
void
run
();
signals
:
void
finished
(
QString
srcUrl
,
QString
resUrl
);
void
signal_asyncCopyFinished
(
int
id
,
bool
pSuccess
,
QUrl
sourceUrl
,
QUrl
contentUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
);
private
:
sDownloadFileDesc
mDesc
;
QString
mFrom
;
QString
mTo
;
};
class
QuaZipFile
;
class
UBProcessingProgressListener
;
class
UBFileSystemUtils
class
UBFileSystemUtils
:
public
QObject
{
Q_OBJECT
public
:
UBFileSystemUtils
();
...
...
src/gui/UBFeaturesWidget.cpp
View file @
ac754bb6
...
...
@@ -1048,8 +1048,8 @@ void UBFeatureProperties::onAddToLib()
desc
.
modal
=
false
;
desc
.
name
=
QFileInfo
(
mpElement
->
getFullPath
().
toString
()).
fileName
();
qDebug
()
<<
desc
.
name
;
desc
.
u
rl
=
mpElement
->
getFullPath
().
toString
();
qDebug
()
<<
desc
.
u
rl
;
desc
.
srcU
rl
=
mpElement
->
getFullPath
().
toString
();
qDebug
()
<<
desc
.
srcU
rl
;
UBDownloadManager
::
downloadManager
()
->
addFileToDownload
(
desc
);
}
}
...
...
src/web/UBTrapFlashController.cpp
View file @
ac754bb6
...
...
@@ -200,7 +200,7 @@ void UBTrapFlashController::createWidget()
// flash widget
UBWebKitUtils
::
HtmlObject
selectedObject
=
mAvailableFlashes
.
at
(
selectedIndex
-
1
);
UBApplication
::
applicationController
->
showBoard
();
UBApplication
::
boardController
->
downloadURL
(
QUrl
(
selectedObject
.
source
),
QPoint
(
0
,
0
),
QSize
(
selectedObject
.
width
,
selectedObject
.
height
));
UBApplication
::
boardController
->
downloadURL
(
QUrl
(
selectedObject
.
source
),
Q
String
(),
Q
Point
(
0
,
0
),
QSize
(
selectedObject
.
width
,
selectedObject
.
height
));
}
QString
freezedWidgetPath
=
UBPlatformUtils
::
applicationResourcesDirectory
()
+
"/etc/freezedWidgetWrapper.html"
;
...
...
src/web/browser/WBWebTrapWebView.cpp
View file @
ac754bb6
...
...
@@ -281,7 +281,7 @@ void WBWebTrapWebView::trapElementAtPos(const QPoint& pos)
emit
objectCaptured
(
QUrl
(
page
()
->
currentFrame
()
->
url
().
toString
()
+
"/"
+
source
),
type
,
htr
.
boundingRect
().
width
(),
htr
.
boundingRect
().
height
());
UBApplication
::
boardController
->
downloadURL
(
QUrl
(
source
)
,
QPointF
(
0.0
,
0.0
)
);
UBApplication
::
boardController
->
downloadURL
(
QUrl
(
source
));
UBApplication
::
applicationController
->
showBoard
();
}
}
...
...
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