Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Aleksei Kanash 13 years ago
commit 484968fea2
  1. 16
      resources/library/search/VideoSearch.wgs/config.xml
  2. 148
      resources/library/search/VideoSearch.wgs/css/basic.css
  3. BIN
      resources/library/search/VideoSearch.wgs/icon.png
  4. BIN
      resources/library/search/VideoSearch.wgs/icon.thumbnail.png
  5. BIN
      resources/library/search/VideoSearch.wgs/images/down.png
  6. BIN
      resources/library/search/VideoSearch.wgs/images/greySquare.png
  7. BIN
      resources/library/search/VideoSearch.wgs/images/icon-close.png
  8. BIN
      resources/library/search/VideoSearch.wgs/images/popupBack.png
  9. BIN
      resources/library/search/VideoSearch.wgs/images/search.png
  10. BIN
      resources/library/search/VideoSearch.wgs/images/trgDown.png
  11. BIN
      resources/library/search/VideoSearch.wgs/images/trgUp.png
  12. BIN
      resources/library/search/VideoSearch.wgs/images/up.png
  13. 279
      resources/library/search/VideoSearch.wgs/index.html
  14. 18
      resources/library/search/VideoSearch.wgs/scripts/jquery-1.6.2.min.js
  15. 13
      src/adaptors/adaptors.pri
  16. 78
      src/adaptors/voting/UBAbstractVotingSystem.cpp
  17. 82
      src/adaptors/voting/UBAbstractVotingSystem.h
  18. 151
      src/adaptors/voting/UBReply2005VotingSystem.cpp
  19. 60
      src/adaptors/voting/UBReply2005VotingSystem.h
  20. 279
      src/adaptors/voting/UBReplyWRS970VotingSystem.cpp
  21. 63
      src/adaptors/voting/UBReplyWRS970VotingSystem.h
  22. 112
      src/api/UBWidgetVotingSystemAPI.cpp
  23. 54
      src/api/UBWidgetVotingSystemAPI.h
  24. 6
      src/api/api.pri
  25. 11
      src/domain/UBW3CWidget.cpp
  26. 2
      src/domain/UBW3CWidget.h

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:ub="http://uniboard.mnemis.com/widgets"
id="http://uniboard.mnemis.com/widgets/webbrowser"
version="1.1"
width="900"
height="500"
ub:resizable="true">
<name>Choisir</name>
<author href="http://www.getuniboard.com"
email="info@mnemis.com">Mnemis SA</author>
<description>Choisir widget</description>
<content src="index.html"/>
</widget>

@ -1,148 +0,0 @@
body{
width: 100%;
padding: 0;
height: auto;
background-color: white;
margin: 0;
}
.disclaimer{
width: 90%;
height: 50px;
position: absolute;
left: 0;
bottom: 0;
margin-left: 1px;
margin-right: 1px;
margin-bottom: 0px;
padding: 5px;
text-align: center;
background-color: #BBBBBB;
-webkit-border-top-left-radius: 15px;
-webkit-border-top-right-radius: 15px;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
border: solid 4px #EEEEEE;
border-bottom: none;
z-index: 10;
}
.search{
width: 90%;
position: absolute;
top: 0;
left: 0;
margin-left: 1px;
margin-right: 1px;
margin-top: 0px;
padding: 5px;
background-color: #BBBBBB;
-webkit-border-bottom-left-radius: 15px;
-webkit-border-bottom-right-radius: 15px;
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
border: solid 4px #EEEEEE;
border-top: none;
z-index: 10;
}
.togglePages{
padding: 0;
position: absolute;
bottom: -14px;
left: 43%;
width: 15%;
height: 10px;
background-color: #666;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
-webkit-box-shadow: #dadada -1px 0 4px;
box-shadow: #dadada -1px 0 4px;
cursor: pointer;
}
.toggleIcon{
width: 14px;
height: 10px;
background-image: url(../images/trgUp.png);
}
.searchInput{
margin: 10px 5px 10px 5px;
padding: 2px;
padding-left: 8px;
padding-right:8px;
float: left;
width: 60%;
border-radius: 15px;
border-style: none;
}
.searchButton{
width: 32px;
height: 32px;
margin: 5px 5px;
background-image: url(../images/search.png);
float: left;
cursor: pointer;
}
.subSearch{
margin: 0;
float: left;
}
#subSearchInput{
width: 100%;
float: left;
}
.searchResult{
width: 98%;
padding: 3px;
background-color:#123456;
}
.videoContainer{
float: left;
padding: 3px;
margin: 3px;
text-align: center;
overflow: hidden;
font-size: small;
font-family: Verdana,Arial,Helvetica,sans-serif;
border: 1px solid #666;
border-radius: 5px;
-webkit-box-shadow: #dadada -1px 0 4px;
-webkit-border-radius: 5px;
box-shadow: #666 -1px 0 4px;
}
.resultFooter{
float: left;
margin: 5px;
padding: 3px;
width: 100%;
font-family: Verdana,Arial,Helvetica,sans-serif;
font-weight: bold;
font-size: x-large;
}
#branding{
position: absolute;
top: 0;
left: 10px;
z-index: 2;
}
span{
font-family: Verdana,Arial,Helvetica,sans-serif;
color: #666;
}
[draggable] {
-webkit-user-select: none;
user-select: none;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

@ -1,279 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Google Image Search</title>
<link rel="stylesheet" type="text/css" href="css/basic.css"/>
<script type="text/javascript" src="http://www.google.com/uds"></script>
<script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
// This code generates a "Raw Searcher" to handle search queries. The Raw Searcher requires
// you to handle and draw the search results manually.
google.load('search', '1');
var videoSearch;
var minHeight = 180;
var minWidht = 150;
var filtersDisplayed = false; //display or hide filters
function addPaginationLinks() {
// To paginate search results, use the cursor function.
var cursor = videoSearch.cursor;
var curPage = cursor.currentPageIndex; // check what page the app is on
var pagesDiv = $("<div id='resultFooter' class='resultFooter'>");
for (var i = 0; i < cursor.pages.length; i++) {
var page = cursor.pages[i];
if (curPage == i) {
// If we are on the current page, then don't make a link.
var label = document.createTextNode(' ' + page.label + ' ');
pagesDiv.append($(label));
} else {
// Create links to other pages using gotoPage() on the searcher.
var link = document.createElement('a');
link.href = 'javascript:videoSearch.gotoPage('+i+');';
link.innerHTML = page.label;
link.style.marginRight = '2px';
pagesDiv.append($(link));
}
}
pagesDiv.appendTo($('#searchResult'));
$(".videoContainer").each(function(){
this.addEventListener("dragstart", imageDragging, false);
})
$(".videoContainer").each(function(){
this.addEventListener("dragenter", imageDragenter, false);
})
$(".videoContainer").each(function(){
this.addEventListener("dragleave", imageDragleave, false);
})
$(".videoContainer").each(function(){
this.addEventListener("dragover", imageDragover, false);
})
}
function searchComplete() {
// Check that we got results
document.getElementById('searchResult').innerHTML = '';
if (videoSearch.results && videoSearch.results.length > 0) {
var contentDiv = $('#searchResult').empty();
var results = videoSearch.results;
for (var i = 0; i < results.length; i++) {
// Create HTML elements for search results
var result = results[i];
/*var str = videoSearch.results[i].playUrl.replace("&autoplay=1","").replace("&autoplay=true","");
alert(str)
a.src = str + "&autoPlay=false";
a.type = "application/x-shockwave-flash";*/
// Append search results to the HTML nodes
//p.appendChild(a);
//document.body.appendChild(p);
var videoContainer = $("<div class='videoContainer' draggable='true'>");
var title = document.createElement('div');
var vUrl = $("<input type='hidden'/>");
var vContent = $("<input type='hidden'/>");
var vHeight = $("<input type='hidden'/>");
var vWidth = $("<input type='hidden'/>");
var vTitle = $("<input type='hidden'/>");
var vAuthor = $("<input type='hidden'/>");
var vDuration = $("<input type='hidden'/>");
var vPublished = $("<input type='hidden'/>");
var vPublisher = $("<input type='hidden'/>");
var vRating = $("<input type='hidden'/>");
var vCount = $("<input type='hidden'/>");
// We use titleNoFormatting so that no HTML tags are left in the
// title
title.innerHTML = result.title;
var newImg = document.createElement('img');
// There is also a result.url property which has the escaped version
newImg.src = result.tbUrl;
//var str = videoSearch.results[i].playUrl.replace("&autoplay=1","").replace("&autoplay=true","");
vUrl.attr("value", result.url);
vContent.attr("value", result.content);
vHeight.attr("value", result.tbHeight);
vWidth.attr("value", result.tbWidth);
vTitle.attr("value",result.titleNoFormatting);
vAuthor.attr("value", result.author);
vDuration.attr("value", result.duration);
vPublished.attr("value", result.published);
vPublisher.attr("value", result.publisher);
vRating.attr("value",result.rating);
vCount.attr("value",result.viewCount);
//var imgWidth = (result.tbWidth > minWidht)?result.tbWidth:minWidht;
//var imgHeight = (result.tbHeight > minHeight)?result.tbHeight:minHeight;
videoContainer.width(minWidht).height(minHeight);
videoContainer.append($(newImg));
videoContainer.append($(title));
videoContainer.append(vUrl);
videoContainer.append(vContent);
videoContainer.append(vHeight);
videoContainer.append(vWidth);
videoContainer.append(vTitle);
videoContainer.append(vAuthor);
videoContainer.append(vDuration);
videoContainer.append(vPublished);
videoContainer.append(vPublisher);
videoContainer.append(vRating);
videoContainer.append(vCount);
// Put our title + image in the content
videoContainer.appendTo(contentDiv);
}
addPaginationLinks(videoSearch);
}
}
function onLoad() {
// Create a VideoSearch instance.
videoSearch = new google.search.VideoSearch();
// Set searchComplete as the callback function when a search is complete. The
// videoSearch object will have results in it.
videoSearch.setSearchCompleteCallback(this, searchComplete, null);
videoSearch.setResultSetSize(8);
// Include the required Google branding
google.search.Search.getBranding('branding');
}
// Set a callback to call your code when the page loads
google.setOnLoadCallback(onLoad);
function imageDragging(e){
e.dataTransfer.setData("text/plain",$(this).find("input:hidden").eq(0).val());
//alert($(this).find("input:hidden").val());
}
function imageDragleave(e){
return false;
}
function imageDragover(e){
return false;
}
function imageDragenter(e){
return false;
}
$(document).ready(function(){
//variables
var mode = false; //search or view mode
var hide = false; //hide or no main panel
//basic containers and elements
var disclaimer = $("<div id='disclaimer' class='disclaimer'>Disclaimer<div>").appendTo("body");
var search = $("<div id='search' class='search'>").appendTo("body");
disclaimer.width($("body").width()-20);
search.width($("body").width()-20);
var togglePages = $("<div id='togglePages' class='togglePages'>").appendTo(search);
var toggleIcon = $("<div id='toggleIcon' class='toggleIcon'>").appendTo(togglePages).css("margin-left",(togglePages.width()/2 - 7));
var subSearchInput = $("<div id='subSearchInput' class='subSearch'>").appendTo(search);
var searchInput = $("<input id='searchInput' class='searchInput' type='text'/>").appendTo(subSearchInput);
var searchButton = $("<div id='searchButton' class='searchButton'>").appendTo(subSearchInput);
togglePages.click(function(event){
if(mode){
hide = false;
$("#search, #disclaimer").slideDown('slow', function(){
toggleIcon.css("background-image","url(images/trgUp.png)");
togglePages.appendTo("#search").css("top","").css("bottom","-14px");
});
mode = false;
} else {
hide = true;
$("#search, #disclaimer").slideUp('slow', function(){
toggleIcon.css("background-image","url(images/trgDown.png)");
togglePages.appendTo("body").css("top","0");
});
mode = true;
}
});
searchButton.click(function(){
if(!hide){
videoSearch.execute(searchInput.val());
togglePages.trigger("click");
}
});
searchInput.keydown(function(event){
if(!hide){
if((event.keyCode == 0xA)||(event.keyCode == 0xD)){
videoSearch.execute(searchInput.val());
togglePages.trigger("click");
}
}
});
$(".videoContainer").live("click",function(){
//alert(createMetaData($(this)));
sankore.sendFileMetadata(createMetaData($(this)));
});
$(window).resize(function(){
disclaimer.width($("body").width()-20);
search.width($("body").width()-20);
toggleIcon.css("margin-left",(togglePages.width()/2 - 7));
})
});
function createMetaData(parent){
var meta = "";
//alert($(this).find("input:hidden").eq(0).val());
meta = "<metadata><data><key>Type</key><value>Video</value></data><data><key>Url</key><value>" +
parent.find("input:hidden").eq(0).val() +
"</value></data><data><key>Content</key><value>" +
parent.find("input:hidden").eq(1).val() +
"</value></data><data><key>tbHeight</key><value>" +
parent.find("input:hidden").eq(2).val() +
"</value></data><data><key>tbWidth</key><value>" +
parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() +
"</value></data><data><key>Author</key><value>" +
parent.find("input:hidden").eq(5).val() +
"</value></data><data><key>Duration</key><value>" +
parent.find("input:hidden").eq(6).val() +
"</value></data><data><key>Published</key><value>" +
parent.find("input:hidden").eq(7).val() +
"</value></data><data><key>Publisher</key><value>" +
parent.find("input:hidden").eq(8).val() +
"</value></data><data><key>Rating</key><value>" +
parent.find("input:hidden").eq(9).val() +
"</value></data><data><key>View count</key><value>" +
parent.find("input:hidden").eq(10).val() +
"</value></data></metadata>";
return meta;
}
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="branding" style="float: left;"></div><br />
<div id="searchResult"></div>
</body>
</html>

File diff suppressed because one or more lines are too long

@ -19,7 +19,6 @@ HEADERS += src/adaptors/UBExportAdaptor.h\
HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \
src/adaptors/publishing/UBSvgSubsetRasterizer.h
HEADERS += src/adaptors/voting/UBAbstractVotingSystem.h
SOURCES += src/adaptors/UBExportAdaptor.cpp\
@ -42,15 +41,3 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\
SOURCES += \
src/adaptors/publishing/UBSvgSubsetRasterizer.cpp
SOURCES += src/adaptors/voting/UBAbstractVotingSystem.cpp
win32 {
SOURCES += src/adaptors/voting/UBReply2005VotingSystem.cpp \
src/adaptors/voting/UBReplyWRS970VotingSystem.cpp
HEADERS += src/adaptors/voting/UBReply2005VotingSystem.h \
src/adaptors/voting/UBReplyWRS970VotingSystem.h
}

@ -1,78 +0,0 @@
/*
* 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 "UBAbstractVotingSystem.h"
#ifdef Q_WS_WIN
#include "UBReply2005VotingSystem.h"
#include "UBReplyWRS970VotingSystem.h"
#endif
#include "gui/UBMainWindow.h"
#include "core/memcheck.h"
UBAbstractVotingSystem::UBAbstractVotingSystem(QObject *parent)
: QObject(parent)
{
// NOOP
}
UBAbstractVotingSystem::~UBAbstractVotingSystem()
{
// NOOP
}
void UBAbstractVotingSystem::setLastError(QString pLastError)
{
mLastError = pLastError;
qDebug() << "Voting System error: " << pLastError;
}
UBAbstractVotingSystem* UBVotingSystemFactory::createVotingSystem()
{
#ifdef Q_WS_WIN
// TODO UB 4.x .. be smarter
UBReplyWRS970VotingSystem* wrs970 = new UBReplyWRS970VotingSystem(UBApplication::mainWindow);
if (wrs970->isVotingSystemAvailable())
return wrs970;
else
{
delete wrs970;
UBReply2005VotingSystem* reply2005 = new UBReply2005VotingSystem(UBApplication::mainWindow);
if (reply2005->isVotingSystemAvailable())
return reply2005;
else
delete reply2005;
return 0;
}
#else
return 0;
#endif
}

@ -1,82 +0,0 @@
/*
* 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 UBABSTRACTVOTINGSYSTEM_H_
#define UBABSTRACTVOTINGSYSTEM_H_
#include <QtCore>
#include "core/UBApplication.h"
class UBAbstractVotingSystem : public QObject
{
Q_OBJECT;
Q_PROPERTY(QString lastError READ lastError);
public:
UBAbstractVotingSystem(QObject *parent = 0);
virtual ~UBAbstractVotingSystem();
virtual bool connectToVotingSystem() = 0;
virtual bool startPolling() = 0;
virtual bool stopPolling() = 0;
virtual bool disconnectFromVotingSystem() = 0;
virtual QMap<int, int> votingState() = 0;
QString lastError() const
{
return mLastError;
}
signals:
void voteReceived(int keypadID, int value);
void errorReceived(const QString& error);
protected:
void setLastError(QString pLastError);
private:
QString mLastError;
};
class UBVotingSystemFactory : public QObject
{
private:
UBVotingSystemFactory()
{
// NOOP
}
~UBVotingSystemFactory()
{
// NOOP
}
public:
static UBAbstractVotingSystem* createVotingSystem();
};
#endif /* UBABSTRACTVOTINGSYSTEM_H_ */

@ -1,151 +0,0 @@
/*
* 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 "UBReply2005VotingSystem.h"
#include "core/UBSettings.h"
#include "core/memcheck.h"
UBReply2005VotingSystem::UBReply2005VotingSystem(QWidget *parent)
: UBAbstractVotingSystem(parent)
, mParent(parent)
, mReplyVotingSystem(0)
, mMaxKeyValue(99)
{
// NOOP
}
UBReply2005VotingSystem::~UBReply2005VotingSystem()
{
if (mReplyVotingSystem)
delete mReplyVotingSystem;
}
bool UBReply2005VotingSystem::isVotingSystemAvailable()
{
if (!mReplyVotingSystem)
mReplyVotingSystem = new ReplyXControl1::ReplyX(mParent);
return (!mReplyVotingSystem->isNull());
}
bool UBReply2005VotingSystem::connectToVotingSystem()
{
bool result = false;
if (isVotingSystemAvailable())
{
connect(mReplyVotingSystem, SIGNAL(OnKeypadDataReceived(int, int)),
this, SLOT(keypadDataReceived(int, int)));
mReplyVotingSystem->SetSerialPort(UBSettings::settings()->replyWWSerialPort->get().toInt());
mReplyVotingSystem->SetReplyModel(ReplyXControl1::mReply2005);
result = mReplyVotingSystem->Connect();
if (!result)
setLastError("Cannot connect to voting system");
}
else
{
setLastError("Reply2005 driver not available");
}
return result;
}
void UBReply2005VotingSystem::keypadDataReceived(int keyPadID, int val)
{
qDebug() << "received vote from " << keyPadID << " : " << val;
mVotes.insert(keyPadID, val);
emit voteReceived(keyPadID, val);
}
bool UBReply2005VotingSystem::startPolling()
{
mVotes.clear();
if (isVotingSystemAvailable())
{
mReplyVotingSystem->StartPolling();
}
else
{
setLastError("Reply2005 driver not available");
}
return true;
}
bool UBReply2005VotingSystem::stopPolling()
{
if (isVotingSystemAvailable())
{
mReplyVotingSystem->StopPolling();
}
else
{
setLastError("Reply2005 driver not available");
}
return true;
}
bool UBReply2005VotingSystem::disconnectFromVotingSystem()
{
if (isVotingSystemAvailable())
{
mReplyVotingSystem->Disconnect();
}
else
{
setLastError("Reply2005 driver not available");
}
return true;
}
QMap<int, int> UBReply2005VotingSystem::votingState()
{
QMap<int, int> results;
for(int i = 0; i < mMaxKeyValue; i++)
{
results.insert(i, 0);
}
foreach(int vote, mVotes.values())
{
int voteCount = 0;
if(results.keys().contains(vote))
{
voteCount = results.value(vote);
voteCount++;
results.insert(vote, voteCount);
}
}
return results;
}

@ -1,60 +0,0 @@
/*
* 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 UBREPLY2005VOTINGSYSTEM_H_
#define UBREPLY2005VOTINGSYSTEM_H_
#include "UBAbstractVotingSystem.h"
#include <QtGui>
#include "replyxcontrol1.h"
class UBReply2005VotingSystem: public UBAbstractVotingSystem
{
Q_OBJECT;
public:
UBReply2005VotingSystem(QWidget *parent = 0);
virtual ~UBReply2005VotingSystem();
public slots:
virtual bool connectToVotingSystem();
virtual bool disconnectFromVotingSystem();
virtual bool startPolling();
virtual bool stopPolling();
virtual QMap<int, int> votingState();
bool isVotingSystemAvailable();
protected:
ReplyXControl1::ReplyX *mReplyVotingSystem;
private:
QWidget* mParent;
QMap <int, int> mVotes;
int mMaxKeyValue;
private slots:
void keypadDataReceived(int, int);
};
#endif /* UBREPLY2005VOTINGSYSTEM_H_ */

@ -1,279 +0,0 @@
/*
* 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 "UBReplyWRS970VotingSystem.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "core/memcheck.h"
UBReplyWRS970VotingSystem::UBReplyWRS970VotingSystem(QWidget *parent)
: UBAbstractVotingSystem(parent)
, mParent(parent)
, mReplyVotingSystem(0)
, mMaxKeyValue(99)
, mCurrentQuestionNumber(0)
{
// NOOP
}
UBReplyWRS970VotingSystem::~UBReplyWRS970VotingSystem()
{
if (mReplyVotingSystem)
delete mReplyVotingSystem;
}
bool UBReplyWRS970VotingSystem::isVotingSystemAvailable()
{
if (!mReplyVotingSystem)
{
mReplyVotingSystem = new WRS970::WRS970X(mParent);
connect(mReplyVotingSystem, SIGNAL(OnKeypadData(QString, int, int, QString, int, QString, int, int)),
this, SLOT(keypadData(QString, int, int, QString, int, QString, int, int)));
connect(mReplyVotingSystem, SIGNAL(OnError(QString)), this, SLOT(error(QString)));
connect(mReplyVotingSystem, SIGNAL(OnDebug(QString)), this, SLOT(debug(QString)));
mReplyVotingSystem->SetVersion3(true);
mReplyVotingSystem->SetExceptionsEnabled(false);
mReplyVotingSystem->SetErrorsEnabled(true);
bool ok;
int maxKeypadsAllowed = UBSettings::settings()->replyPlusMaxKeypads->get().toInt(&ok);
if (ok)
{
mReplyVotingSystem->SetMaxKeypadsAllowed(maxKeypadsAllowed);
for(int i = 0 ; i < maxKeypadsAllowed; i += 100)
{
mReplyVotingSystem->AddStaticKeypad("00000", i + 1, true);
}
}
if (UBApplication::app()->isVerbose())
{
mReplyVotingSystem->SetDebugEnabled(true);
}
}
return (!mReplyVotingSystem->isNull());
}
bool UBReplyWRS970VotingSystem::connectToVotingSystem()
{
bool connected = false;
if (isVotingSystemAvailable())
{
mCurrentQuestionNumber = 0;
QString targetBase;
QString connectionURL = UBSettings::settings()->replyPlusConnectionURL->get().toString();
if (connectionURL.toLower() == "usb")
{
QString baseSerial = mReplyVotingSystem->GetAvailableBases(false);
if (baseSerial == "No device found")
{
setLastError("No WRS970 device found via USB");
return false;
}
QStringList bases = baseSerial.split(",");
if (bases.count() == 0)
{
setLastError("No base found via USB");
return false;
}
targetBase = bases.at(0);
mReplyVotingSystem->Connect(targetBase);
}
else
{
QString ip;
QString port;
targetBase = connectionURL;
QStringList addressTokens = connectionURL.split(":");
if (addressTokens.length() > 0)
ip = addressTokens.at(0);
if (addressTokens.length() > 1)
port = addressTokens.at(1);
if (ip.length() > 0)
{
mReplyVotingSystem->SetCommType(WRS970::ctTCP);
mReplyVotingSystem->SetTCPAddress(ip);
bool ok;
int iPort = port.toInt(&ok);
if (port.length() > 0 && ok)
mReplyVotingSystem->SetTCPPort(iPort);
}
mReplyVotingSystem->Connect(NULL);
}
connected = mReplyVotingSystem->Connected();
if (!connected)
setLastError("Error connecting to base " + targetBase);
qDebug() << "Reply WRS 970 connected:" << connected;
if (connected)
{
QString addressingMode = UBSettings::settings()->replyPlusAddressingMode->get().toString();
if (addressingMode.toLower() == "static")
mReplyVotingSystem->SetAddressMode(WRS970::addrStatic);
else
mReplyVotingSystem->SetAddressMode(WRS970::addrDynamic);
}
}
else
{
setLastError("WRS970 driver not available");
}
return connected;
}
void UBReplyWRS970VotingSystem::keypadData(QString serialNumber, int keypadID, int timeStamp, QString version
, int batteryLevel, QString value, int questionNumber, int keypadType)
{
Q_UNUSED(serialNumber);
Q_UNUSED(timeStamp);
Q_UNUSED(version);
Q_UNUSED(batteryLevel);
Q_UNUSED(questionNumber);
Q_UNUSED(keypadType);
qDebug() << "Received vote from " << keypadID << " : " << value;
mVotes.insert(keypadID, value.toInt());
emit voteReceived(keypadID, value.toInt());
}
void UBReplyWRS970VotingSystem::error(QString error)
{
setLastError(error);
emit errorReceived(error);
//UBApplication::showMessage(tr("Voting System Error: %1").arg(error));
}
void UBReplyWRS970VotingSystem::debug(QString error)
{
qDebug() << error;
}
bool UBReplyWRS970VotingSystem::startPolling()
{
mVotes.clear();
if (isVotingSystemAvailable())
{
++mCurrentQuestionNumber;
mReplyVotingSystem->BeginQuestion(mCurrentQuestionNumber, WRS970::atSingleDigit);
}
else
{
setLastError("WRS970 driver not available");
}
return true;
}
bool UBReplyWRS970VotingSystem::stopPolling()
{
if (isVotingSystemAvailable())
{
//mReplyVotingSystem->
}
else
{
setLastError("WRS970 driver not available");
}
return true;
}
bool UBReplyWRS970VotingSystem::disconnectFromVotingSystem()
{
if (isVotingSystemAvailable())
{
mReplyVotingSystem->Disconnect();
}
else
{
setLastError("WRS970 driver not available");
}
return true;
}
QMap<int, int> UBReplyWRS970VotingSystem::votingState()
{
QMap<int, int> results;
for(int i = 0; i < mMaxKeyValue; i++)
{
results.insert(i, 0);
}
foreach(int vote, mVotes.values())
{
if(results.keys().contains(vote))
{
int voteCount = results.value(vote);
voteCount++;
results.insert(vote, voteCount);
}
}
foreach(int key, results.keys())
{
qDebug() << "Vote" << key << ":" << results.value(key);
}
return results;
}

@ -1,63 +0,0 @@
/*
* 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 UBREPLYWRS970VOTINGSYSTEM_H_
#define UBREPLYWRS970VOTINGSYSTEM_H_
#include "UBAbstractVotingSystem.h"
#include "wrs970.h"
class UBReplyWRS970VotingSystem : public UBAbstractVotingSystem
{
Q_OBJECT;
public:
UBReplyWRS970VotingSystem(QWidget *parent = 0);
virtual ~UBReplyWRS970VotingSystem();
public slots:
virtual bool connectToVotingSystem();
virtual bool disconnectFromVotingSystem();
virtual bool startPolling();
virtual bool stopPolling();
virtual QMap<int, int> votingState();
bool isVotingSystemAvailable();
protected:
WRS970::WRS970X *mReplyVotingSystem;
private:
QWidget* mParent;
QMap <int, int> mVotes;
int mMaxKeyValue;
int mCurrentQuestionNumber;
private slots:
void keypadData(QString, int, int, QString, int, QString, int, int);
void error(QString error);
void debug(QString error);
};
#endif /* UBREPLYWRS970VOTINGSYSTEM_H_ */

@ -1,112 +0,0 @@
/*
* 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 "UBWidgetVotingSystemAPI.h"
#include "adaptors/voting/UBAbstractVotingSystem.h"
#include "core/memcheck.h"
UBWidgetVotingSystemAPI::UBWidgetVotingSystemAPI(QObject* parent)
: QObject(parent)
, mVotingSystem(0)
{
// NOOP
}
UBWidgetVotingSystemAPI::~UBWidgetVotingSystemAPI()
{
// NOOP
}
QString UBWidgetVotingSystemAPI::lastError()
{
return mLastError;
}
void UBWidgetVotingSystemAPI::setLastError(const QString& pLastError)
{
mLastError = pLastError;
qDebug() << mLastError;
emit error(mLastError);
}
void UBWidgetVotingSystemAPI::errorReceived(const QString& pLastError)
{
setLastError(pLastError);
}
bool UBWidgetVotingSystemAPI::startPoll()
{
if (!mVotingSystem)
{
mVotingSystem = UBVotingSystemFactory::createVotingSystem();
}
if (!mVotingSystem)
{
setLastError("No voting system available");
return false;
}
connect(mVotingSystem, SIGNAL(errorReceived(const QString&)), this, SLOT(errorReceived(const QString&)));
bool connected = mVotingSystem->connectToVotingSystem();
if (!connected)
{
return false;
}
bool started = mVotingSystem->startPolling();
if (!started)
{
return false;
}
return true;
}
QVariantMap UBWidgetVotingSystemAPI::closePoll()
{
if (!mVotingSystem)
return QVariantMap();
mVotingSystem->stopPolling();
QMap<int, int> results = mVotingSystem->votingState();
mVotingSystem->disconnectFromVotingSystem();
delete mVotingSystem;
mVotingSystem = 0;
QVariantMap scriptResults;
foreach(int key, results.keys())
{
scriptResults.insert(QString("%1").arg(key), QVariant(results.value(key)));
}
return scriptResults;
}

@ -1,54 +0,0 @@
/*
* 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 UBWIDGETVOTINGSYSTEMAPI_H_
#define UBWIDGETVOTINGSYSTEMAPI_H_
#include <QtCore>
class UBAbstractVotingSystem;
class UBWidgetVotingSystemAPI : public QObject
{
Q_OBJECT;
Q_PROPERTY(QString lastError READ lastError);
public:
UBWidgetVotingSystemAPI(QObject* parent = 0);
virtual ~UBWidgetVotingSystemAPI();
QString lastError();
void setLastError(const QString& pLastError);
signals:
void error(const QString&);
public slots:
bool startPoll();
QVariantMap closePoll();
private slots:
void errorReceived(const QString& error);
private:
UBAbstractVotingSystem* mVotingSystem;
QString mLastError;
};
#endif /* UBWIDGETVOTINGSYSTEMAPI_H_ */

@ -2,14 +2,12 @@
HEADERS += src/api/UBWidgetUniboardAPI.h \
src/api/UBLibraryAPI.h \
src/api/UBW3CWidgetAPI.h \
src/api/UBWidgetMessageAPI.h \
src/api/UBWidgetVotingSystemAPI.h
src/api/UBWidgetMessageAPI.h
SOURCES += src/api/UBWidgetUniboardAPI.cpp \
src/api/UBLibraryAPI.cpp \
src/api/UBW3CWidgetAPI.cpp \
src/api/UBWidgetMessageAPI.cpp \
src/api/UBWidgetVotingSystemAPI.cpp
src/api/UBWidgetMessageAPI.cpp

@ -24,7 +24,6 @@
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "api/UBWidgetUniboardAPI.h"
#include "api/UBWidgetVotingSystemAPI.h"
#include "board/UBBoardController.h"
@ -219,18 +218,8 @@ void UBW3CWidget::javaScriptWindowObjectCleared()
page()->mainFrame()->addToJavaScriptWindowObject("sankore", uniboardAPI);
UBWidgetVotingSystemAPI *votingSystem = new UBWidgetVotingSystemAPI(this);
page()->mainFrame()->addToJavaScriptWindowObject("voting", votingSystem);
connect(votingSystem, SIGNAL(error(const QString&)) , this, SLOT(votingSystemError(const QString&)));
}
void UBW3CWidget::votingSystemError(const QString& error)
{
page()->mainFrame()->evaluateJavaScript("if(voting.onerror) { voting.onerror('" + error +"');}");
}
bool UBW3CWidget::hasNPAPIWrapper(const QString& pMimeType)
{
loadNPAPIWrappersTemplates();

@ -117,8 +117,6 @@ class UBW3CWidget : public UBAbstractWidget
void javaScriptWindowObjectCleared();
void votingSystemError(const QString&);
};
#endif /* UBW3CWIDGET_H_ */

Loading…
Cancel
Save