├── gui ├── sounds │ ├── ring3.wav │ ├── ringin.wav │ ├── incomingcall.wav │ ├── outgoingcall.wav │ └── outgoingcallbusy.wav ├── images │ ├── call-hold.png │ ├── call-stop.png │ ├── camera-on.png │ ├── call-start.png │ ├── camera-off.png │ ├── call-hold-22.png │ ├── call-start-22.png │ ├── call-stop-22.png │ ├── video-icon-big.png │ ├── video-icon-off.png │ ├── video-icon-on.png │ ├── audio-volume-high.png │ ├── audio-volume-muted.png │ ├── audio-volume-muted-22.png │ └── audio-volume-medium-22.png ├── webenginepagepanel.cpp ├── WebViewNotify.cpp ├── webenginepagepanel.h ├── WebView_images.qrc ├── webtabcontents.h ├── filedownloader.h ├── WebViewMainpage.h ├── filedownloader.cpp ├── webviewrs.h ├── webenginepagepanel.ui ├── webtabcontents.ui ├── WebViewMainpage.ui ├── WebViewNotify.h ├── webtabcontents.cpp ├── webbridgers.h ├── WebViewMainpage.cpp └── webviewrs.cpp ├── rshtml ├── ivank │ ├── car.png │ ├── asphalt.jpg │ └── kevents.html ├── audio │ └── receive.wav ├── loading.html ├── cmtest.html ├── codemirror │ ├── mode │ │ ├── javascript │ │ │ ├── test.js │ │ │ ├── typescript.html │ │ │ └── index.html │ │ ├── css │ │ │ ├── index.html │ │ │ ├── scss_test.js │ │ │ ├── scss.html │ │ │ └── test.js │ │ ├── xml │ │ │ └── index.html │ │ └── htmlmixed │ │ │ ├── index.html │ │ │ └── htmlmixed.js │ └── codemirror.css ├── acetest.html ├── listforums.html ├── extimgtest.html ├── downloadurl.html ├── js │ ├── THREEx.WindowResize.js │ ├── Detector.js │ ├── Stats.js │ ├── THREEx.FullScreen.js │ └── THREEx.KeyboardState.js ├── style.css ├── improvedbroadcastchat.html ├── broadcastchat.html ├── select.html ├── nicehtml │ ├── style.css │ └── index.html ├── directchat.html ├── friends.html ├── search2.html ├── viewforum.html ├── localstorage.html ├── search3.html ├── term_tree.js ├── preview.html ├── tree.html ├── search.html ├── index.html ├── speech.js ├── interactiveparticles.html ├── libsha512.js └── Texture-From-Canvas.html ├── .gitmodules ├── cptest ├── docs └── Mainpage.dox ├── rename_plugin.sh ├── README.md ├── interface └── rsWebView.h ├── WebView.pro ├── WebViewPlugin.h ├── services ├── p3WebView.h ├── rsWebViewItems.h ├── rsWebViewItems.cc └── p3WebView.cc ├── html_rc.qrc └── WebViewPlugin.cpp /gui/sounds/ring3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/sounds/ring3.wav -------------------------------------------------------------------------------- /gui/sounds/ringin.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/sounds/ringin.wav -------------------------------------------------------------------------------- /rshtml/ivank/car.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/rshtml/ivank/car.png -------------------------------------------------------------------------------- /gui/images/call-hold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/call-hold.png -------------------------------------------------------------------------------- /gui/images/call-stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/call-stop.png -------------------------------------------------------------------------------- /gui/images/camera-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/camera-on.png -------------------------------------------------------------------------------- /rshtml/audio/receive.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/rshtml/audio/receive.wav -------------------------------------------------------------------------------- /rshtml/ivank/asphalt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/rshtml/ivank/asphalt.jpg -------------------------------------------------------------------------------- /gui/images/call-start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/call-start.png -------------------------------------------------------------------------------- /gui/images/camera-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/camera-off.png -------------------------------------------------------------------------------- /gui/images/call-hold-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/call-hold-22.png -------------------------------------------------------------------------------- /gui/images/call-start-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/call-start-22.png -------------------------------------------------------------------------------- /gui/images/call-stop-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/call-stop-22.png -------------------------------------------------------------------------------- /gui/images/video-icon-big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/video-icon-big.png -------------------------------------------------------------------------------- /gui/images/video-icon-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/video-icon-off.png -------------------------------------------------------------------------------- /gui/images/video-icon-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/video-icon-on.png -------------------------------------------------------------------------------- /gui/sounds/incomingcall.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/sounds/incomingcall.wav -------------------------------------------------------------------------------- /gui/sounds/outgoingcall.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/sounds/outgoingcall.wav -------------------------------------------------------------------------------- /gui/sounds/outgoingcallbusy.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/sounds/outgoingcallbusy.wav -------------------------------------------------------------------------------- /gui/images/audio-volume-high.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/audio-volume-high.png -------------------------------------------------------------------------------- /gui/images/audio-volume-muted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/audio-volume-muted.png -------------------------------------------------------------------------------- /gui/images/audio-volume-muted-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/audio-volume-muted-22.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "html"] 2 | path = html 3 | url = git@github.com:RetroShare/ExampleRSPlugin.git 4 | branch = gh-pages 5 | -------------------------------------------------------------------------------- /gui/images/audio-volume-medium-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chozabu/WebViewRS/master/gui/images/audio-volume-medium-22.png -------------------------------------------------------------------------------- /cptest: -------------------------------------------------------------------------------- 1 | kdesudo -u retrotester cp lib*.so* /home/retrotester/.retroshare/extensions6/ 2 | kdesudo -u retrotester /home/chozabu/git/RetroShare/retroshare-gui/src/RetroShare 3 | 4 | -------------------------------------------------------------------------------- /rshtml/loading.html: -------------------------------------------------------------------------------- 1 | Download Test 2 | 3 | 4 | 5 | 6 | Loading... 7 | 8 | 9 | -------------------------------------------------------------------------------- /gui/webenginepagepanel.cpp: -------------------------------------------------------------------------------- 1 | #include "webenginepagepanel.h" 2 | #include "ui_webenginepagepanel.h" 3 | 4 | WebViewPagePanel::WebViewPagePanel(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::WebViewPagePanel) 7 | { 8 | ui->setupUi(this); 9 | 10 | } 11 | 12 | WebViewPagePanel::~WebViewPagePanel() 13 | { 14 | delete ui; 15 | } 16 | -------------------------------------------------------------------------------- /docs/Mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @brief Documentation for the RetroShare Chatserver Sources 3 | @author chozabu & cave 4 | @file 5 | */ 6 | /** @defgroup RetroShare */ 7 | /** 8 | @mainpage RetroShare Example Plugin 9 | This guide should help you to create your own Plugin. 10 | It should point you to the direction how to untangle the code and run some networking. 11 | */ 12 | -------------------------------------------------------------------------------- /gui/WebViewNotify.cpp: -------------------------------------------------------------------------------- 1 | #include "WebViewNotify.h" 2 | 3 | WebViewNotify::WebViewNotify(QObject *parent) : QObject(parent) 4 | { 5 | 6 | } 7 | 8 | 9 | 10 | void WebViewNotify::notifyReceivedMsg(const RsPeerId& peer_id, QString str) 11 | { 12 | std::cout << "pNotify Recvd Packet from: " << peer_id; 13 | std::cout << " saying " << str.toStdString(); 14 | std::cout << std::endl; 15 | emit NeMsgArrived(peer_id, str) ; 16 | } 17 | -------------------------------------------------------------------------------- /rename_plugin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | newname=$1 3 | oldname="WebView" 4 | echo "$newname" 5 | echo "$oldname" 6 | find . -not -path '*/\.*' -type f -print0 | xargs -0 sed -i "s/$oldname/$newname/g" 7 | #find . -type f -exec rename "s/$oldname/$newname/' '{}" \; 8 | find . | sed -e "p;s/$oldname/$newname/" | xargs -n2 git mv 9 | 10 | echo "now change 0xb00b5 in services/*items.h to a unique value of your choice to identify your plugin!" 11 | -------------------------------------------------------------------------------- /gui/webenginepagepanel.h: -------------------------------------------------------------------------------- 1 | #ifndef WEBENGINEPAGEPANEL_H 2 | #define WEBENGINEPAGEPANEL_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class WebViewPagePanel; 8 | } 9 | 10 | class WebViewPagePanel : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit WebViewPagePanel(QWidget *parent = 0); 16 | ~WebViewPagePanel(); 17 | 18 | private: 19 | Ui::WebViewPagePanel *ui; 20 | }; 21 | 22 | #endif // WEBENGINEPAGEPANEL_H 23 | -------------------------------------------------------------------------------- /rshtml/cmtest.html: -------------------------------------------------------------------------------- 1 | cmtest 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | asd 17 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/javascript/test.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var mode = CodeMirror.getMode({indentUnit: 2}, "javascript"); 3 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } 4 | 5 | MT("locals", 6 | "[keyword function] [variable foo]([def a], [def b]) { [keyword var] [def c] = [number 10]; [keyword return] [variable-2 a] + [variable-2 c] + [variable d]; }"); 7 | 8 | MT("comma-and-binop", 9 | "[keyword function](){ [keyword var] [def x] = [number 1] + [number 2], [def y]; }"); 10 | })(); 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WebViewRS 2 | ================== 3 | 4 | This plugin contains a widget with tabbed QWebView - like a tabbed browser 5 | The WebViews have access to some RS Features like file search, or sending data to peers running the same plugin. 6 | 7 | ##Compile & run 8 | 9 | Depends on qt5.4+ 10 | 11 | this plugin should be built in the retroshare plugins directory, along the lines of: 12 | 13 | cd myretrosharedir/plugins 14 | git clone 15 | cd 16 | qmake 17 | make 18 | cp *so* ~/.retroshare/extensions6/ 19 | 20 | Then reboot retroshare, it will ask if you want to accept the plugin. 21 | 22 | -------------------------------------------------------------------------------- /gui/WebView_images.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/audio-volume-high.png 4 | images/muted_self.svg 5 | images/audio-volume-muted.png 6 | images/talking_on.svg 7 | images/talking_off.svg 8 | images/call-start.png 9 | images/call-stop.png 10 | images/call-hold.png 11 | images/camera-on.png 12 | images/camera-off.png 13 | images/video-icon-big.png 14 | images/video-icon-on.png 15 | images/video-icon-off.png 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /rshtml/acetest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ACE in Action 5 | 14 | 15 | 16 | 17 |
function foo(items) { 18 | var x = "All this is syntax highlighted"; 19 | return x; 20 | }
21 | 22 | 23 | 27 | 28 | -------------------------------------------------------------------------------- /gui/webtabcontents.h: -------------------------------------------------------------------------------- 1 | #ifndef WEBTABCONTENTS_H 2 | #define WEBTABCONTENTS_H 3 | 4 | #include 5 | #include "webviewrs.h" 6 | 7 | namespace Ui { 8 | class WebTabContents; 9 | } 10 | 11 | class WebTabContents : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit WebTabContents(QWidget *parent = 0); 17 | ~WebTabContents(); 18 | WebViewRS *getWebView(); 19 | 20 | protected slots: 21 | void adjustLocation(); 22 | void changeLocation(); 23 | 24 | protected: 25 | void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID); 26 | private: 27 | Ui::WebTabContents *ui; 28 | WebViewRS* webview; 29 | }; 30 | 31 | #endif // WEBTABCONTENTS_H 32 | -------------------------------------------------------------------------------- /rshtml/listforums.html: -------------------------------------------------------------------------------- 1 | Index 2 | 3 | 4 | 5 | Back to Index
6 | 7 |
8 | Subscribed Forums: 9 |

10 | 11 | 12 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /rshtml/extimgtest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | three.js webgl - geometry - cube 7 | 8 | 9 |

Original external image

10 | 11 | 12 | 24 | 25 | -------------------------------------------------------------------------------- /gui/filedownloader.h: -------------------------------------------------------------------------------- 1 | #ifndef FILEDOWNLOADER_H 2 | #define FILEDOWNLOADER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class FileDownloader : public QObject 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit FileDownloader(QUrl imageUrl, QObject *parent = 0); 16 | 17 | virtual ~FileDownloader(); 18 | 19 | QByteArray downloadedData() const; 20 | QUrl url() const; 21 | 22 | signals: 23 | void downloaded(); 24 | 25 | private slots: 26 | 27 | void fileDownloaded(QNetworkReply* pReply); 28 | 29 | private: 30 | 31 | QNetworkAccessManager m_WebCtrl; 32 | 33 | QByteArray m_DownloadedData; 34 | QUrl m_Url; 35 | 36 | }; 37 | 38 | #endif // FILEDOWNLOADER_H 39 | -------------------------------------------------------------------------------- /gui/WebViewMainpage.h: -------------------------------------------------------------------------------- 1 | /* This is the main page displayed by the plugin */ 2 | #ifndef NEMAINPAGE_H 3 | #define NEMAINPAGE_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include "gui/WebViewNotify.h" 9 | 10 | 11 | 12 | #include 13 | 14 | namespace Ui { 15 | class WebViewMainpage; 16 | } 17 | 18 | class WebViewMainpage : public MainPage 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit WebViewMainpage(QWidget *parent, WebViewNotify *notify); 24 | ~WebViewMainpage(); 25 | 26 | private slots: 27 | void on_pingAllButton_clicked(); 28 | void NeMsgArrived(const RsPeerId &peer_id, QString str); 29 | 30 | void on_broadcastButton_clicked(); 31 | private: 32 | Ui::WebViewMainpage *ui; 33 | WebViewNotify *mNotify; 34 | }; 35 | 36 | #endif // NEMAINPAGE_H 37 | -------------------------------------------------------------------------------- /gui/filedownloader.cpp: -------------------------------------------------------------------------------- 1 | #include "filedownloader.h" 2 | 3 | FileDownloader::FileDownloader(QUrl imageUrl, QObject *parent) : 4 | QObject(parent) 5 | { 6 | m_Url = imageUrl; 7 | connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)), 8 | SLOT(fileDownloaded(QNetworkReply*))); 9 | 10 | QNetworkRequest request(imageUrl); 11 | m_WebCtrl.get(request); 12 | } 13 | 14 | FileDownloader::~FileDownloader() 15 | { 16 | 17 | } 18 | 19 | void FileDownloader::fileDownloaded(QNetworkReply* pReply) 20 | { 21 | m_DownloadedData = pReply->readAll(); 22 | //emit a signal 23 | pReply->deleteLater(); 24 | emit downloaded(); 25 | } 26 | 27 | QByteArray FileDownloader::downloadedData() const 28 | { 29 | return m_DownloadedData; 30 | } 31 | 32 | QUrl FileDownloader::url() const 33 | { 34 | return m_Url; 35 | } 36 | -------------------------------------------------------------------------------- /gui/webviewrs.h: -------------------------------------------------------------------------------- 1 | #ifndef WEBVIEWRS_H 2 | #define WEBVIEWRS_H 3 | 4 | #include 5 | #include 6 | #include 7 | //#include "p3JsonRS.h" 8 | 9 | /*this class along with webbridgers is passed to the browser as a JS object.*/ 10 | class WebViewRS : public QWebView 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit WebViewRS(QWidget *parent = 0); 15 | ~WebViewRS(); 16 | 17 | public slots: 18 | void onJavaScriptWindowObjectCleared(); 19 | void onLinkClicked(const QUrl & url); 20 | void onDownloadComplete(QString hash); 21 | void loadRSFile(QString qname, QString qhash, int qsize); 22 | 23 | void go2page(QString url); 24 | void onChange(); 25 | void setHashQue(QString hash); 26 | signals: 27 | void onNewTabUrl(QString url); 28 | void requestTabForHash(QString url); 29 | private: 30 | QString hashque; 31 | 32 | }; 33 | 34 | #endif // WEBVIEWRS_H 35 | -------------------------------------------------------------------------------- /gui/webenginepagepanel.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WebViewPagePanel 4 | 5 | 6 | 7 | 0 8 | 0 9 | 581 10 | 426 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Go 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /gui/webtabcontents.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WebTabContents 4 | 5 | 6 | 7 | 0 8 | 0 9 | 963 10 | 640 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Go 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /rshtml/downloadurl.html: -------------------------------------------------------------------------------- 1 | Download Test 2 | 3 | 4 | 5 | 6 | 7 | back to index
8 | 9 | 10 |

11 | 12 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /rshtml/js/THREEx.WindowResize.js: -------------------------------------------------------------------------------- 1 | // This THREEx helper makes it easy to handle window resize. 2 | // It will update renderer and camera when window is resized. 3 | // 4 | // # Usage 5 | // 6 | // **Step 1**: Start updating renderer and camera 7 | // 8 | // ```var windowResize = THREEx.WindowResize(aRenderer, aCamera)``` 9 | // 10 | // **Step 2**: Start updating renderer and camera 11 | // 12 | // ```windowResize.stop()``` 13 | // # Code 14 | 15 | // 16 | 17 | /** @namespace */ 18 | var THREEx = THREEx || {}; 19 | 20 | /** 21 | * Update renderer and camera when the window is resized 22 | * 23 | * @param {Object} renderer the renderer to update 24 | * @param {Object} Camera the camera to update 25 | */ 26 | THREEx.WindowResize = function(renderer, camera){ 27 | var callback = function(){ 28 | // notify the renderer of the size change 29 | renderer.setSize( window.innerWidth, window.innerHeight ); 30 | // update the camera 31 | camera.aspect = window.innerWidth / window.innerHeight; 32 | camera.updateProjectionMatrix(); 33 | } 34 | // bind the resize event 35 | window.addEventListener('resize', callback, false); 36 | // return .stop() the function to stop watching window resize 37 | return { 38 | /** 39 | * Stop watching window resize 40 | */ 41 | stop : function(){ 42 | window.removeEventListener('resize', callback); 43 | } 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /rshtml/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: url(texture-noise.png); 3 | overflow: hidden; 4 | margin: 0; 5 | font-size: 14px; 6 | font-family: "Helvetica Neue", Helvetica; 7 | } 8 | 9 | #chart, #header, #footer { 10 | position: absolute; 11 | top: 0; 12 | } 13 | 14 | #header, #footer { 15 | z-index: 1; 16 | display: block; 17 | font-size: 36px; 18 | font-weight: 300; 19 | text-shadow: 0 1px 0 #fff; 20 | } 21 | 22 | #header.inverted, #footer.inverted { 23 | color: #fff; 24 | text-shadow: 0 1px 4px #000; 25 | } 26 | 27 | #header { 28 | top: 80px; 29 | left: 140px; 30 | width: 1000px; 31 | } 32 | 33 | #footer { 34 | top: 680px; 35 | right: 140px; 36 | text-align: right; 37 | } 38 | 39 | rect { 40 | fill: none; 41 | pointer-events: all; 42 | } 43 | 44 | pre { 45 | font-size: 18px; 46 | } 47 | 48 | line { 49 | stroke: #000; 50 | stroke-width: 1.5px; 51 | } 52 | 53 | .string, .regexp { 54 | color: #f39; 55 | } 56 | 57 | .keyword { 58 | color: #00c; 59 | } 60 | 61 | .comment { 62 | color: #777; 63 | font-style: oblique; 64 | } 65 | 66 | .number { 67 | color: #369; 68 | } 69 | 70 | .class, .special { 71 | color: #1181B8; 72 | } 73 | 74 | a:link, a:visited { 75 | color: #000; 76 | text-decoration: none; 77 | } 78 | 79 | a:hover { 80 | color: #666; 81 | } 82 | 83 | .hint { 84 | position: absolute; 85 | right: 0; 86 | width: 1280px; 87 | font-size: 12px; 88 | color: #999; 89 | } -------------------------------------------------------------------------------- /gui/WebViewMainpage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WebViewMainpage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 735 10 | 514 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | New Tab 23 | 24 | 25 | 26 | 27 | 28 | 29 | Close Tab 30 | 31 | 32 | 33 | 34 | 35 | 36 | Refresh Tab 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -1 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /rshtml/improvedbroadcastchat.html: -------------------------------------------------------------------------------- 1 | Index 2 | 3 | 4 | Back to Index
5 | 6 |
7 | Feed: 8 |

9 | 44 | -------------------------------------------------------------------------------- /rshtml/broadcastchat.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | Broadcast Chat 10 | 11 | 40 | 41 | 42 | 43 |

Back to index

44 |

45 | Chat: 46 |
47 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/javascript/typescript.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeMirror: TypeScript mode 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 24 | 25 |
26 |

TypeScript mode

27 | 28 | 29 |
51 | 52 | 59 | 60 |

This is a specialization of the JavaScript mode.

61 |
62 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/css/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeMirror: CSS mode 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 24 | 25 |
26 |

CSS mode

27 |
62 | 65 | 66 |

MIME types defined: text/css.

67 | 68 |

Parsing/Highlighting Tests: normal, verbose.

69 | 70 |
71 | -------------------------------------------------------------------------------- /rshtml/select.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | viz encoder 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 40 | 41 |

Please allow access to mic.

42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
while addiction is still being researched, here is the simple version of what we know so far, okay: 52 |
53 |
There is a certain part of your brain called the nucleus 54 | accumbens which plays a huge part in your brain's reward circuits, 55 | simply put, if you desire something: 56 |
a piece of chocolate, megan fox, 57 |
a neurotransmitter called dopamine rises in the outer shell of your nucleus accumbens,
58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /gui/WebViewNotify.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * RetroShare is distributed under the following license: 3 | * 4 | * Copyright (C) 2015 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | ****************************************************************/ 21 | 22 | // This class is a Qt object to get notification from the plugin's service threads, 23 | // and responsible to pass the info the the GUI part. 24 | // 25 | // Because the GUI part is async-ed with the service, it is crucial to use the 26 | // QObject connect system to communicate between the p3Service and the gui part (handled by Qt) 27 | // 28 | #ifndef NETEXAMPLENOTIFY_H 29 | #define NETEXAMPLENOTIFY_H 30 | 31 | #include 32 | 33 | #include 34 | 35 | class WebViewNotify : public QObject 36 | { 37 | Q_OBJECT 38 | public: 39 | explicit WebViewNotify(QObject *parent = 0); 40 | void notifyReceivedMsg(const RsPeerId &peer_id, QString str) ; 41 | 42 | signals: 43 | void NeMsgArrived(const RsPeerId &peer_id, QString str) ; // emitted when the peer gets a msg 44 | 45 | public slots: 46 | }; 47 | 48 | #endif // NETEXAMPLENOTIFY_H 49 | -------------------------------------------------------------------------------- /rshtml/nicehtml/style.css: -------------------------------------------------------------------------------- 1 | #container 2 | { 3 | margin: 0 auto; 4 | width: 100%; 5 | background: #fff; 6 | } 7 | 8 | #header 9 | { 10 | background: #ccc; 11 | padding: 20px; 12 | } 13 | 14 | #header h1 { margin: 0; } 15 | 16 | #navigation 17 | { 18 | float: left; 19 | width: 100%; 20 | background: #333; 21 | } 22 | 23 | #navigation ul 24 | { 25 | margin: 0; 26 | padding: 0; 27 | } 28 | 29 | #navigation ul li 30 | { 31 | list-style-type: none; 32 | display: inline; 33 | } 34 | 35 | #navigation li a 36 | { 37 | display: block; 38 | float: left; 39 | padding: 5px 10px; 40 | color: #fff; 41 | text-decoration: none; 42 | border-right: 1px solid #fff; 43 | } 44 | 45 | #navigation li a:hover { background: #383; } 46 | 47 | #content-container1 48 | { 49 | float: left; 50 | width: 100%; 51 | background: #fff url(/wp-content/uploads/layout-three-liquid-background1.gif) repeat-y 20% 0; 52 | } 53 | 54 | #content-container2 55 | { 56 | float: left; 57 | width: 100%; 58 | background: url(/wp-content/uploads/layout-three-liquid-background2.gif) repeat-y 80% 0; 59 | } 60 | 61 | #section-navigation 62 | { 63 | float: left; 64 | width: 16%; 65 | padding: 20px 0; 66 | margin: 0 2%; 67 | display: inline; 68 | } 69 | 70 | #section-navigation ul 71 | { 72 | margin: 0; 73 | padding: 0; 74 | } 75 | 76 | #section-navigation ul li 77 | { 78 | margin: 0 0 1em; 79 | padding: 0; 80 | list-style-type: none; 81 | } 82 | 83 | #content 84 | { 85 | float: left; 86 | width: 56%; 87 | padding: 20px 0; 88 | margin: 0 0 0 2%; 89 | } 90 | 91 | #content h2 { margin: 0; } 92 | 93 | #aside 94 | { 95 | float: right; 96 | width: 16%; 97 | padding: 20px 0; 98 | margin: 0 2% 0 0; 99 | display: inline; 100 | } 101 | 102 | #aside h3 { margin: 0; } 103 | 104 | #footer 105 | { 106 | clear: both; 107 | background: #ccc; 108 | text-align: right; 109 | padding: 20px; 110 | height: 1%; 111 | } -------------------------------------------------------------------------------- /gui/webtabcontents.cpp: -------------------------------------------------------------------------------- 1 | #include "webtabcontents.h" 2 | #include "ui_webtabcontents.h" 3 | 4 | //#incude "QTextBrowser" 5 | 6 | WebTabContents::WebTabContents(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::WebTabContents) 9 | { 10 | this->setObjectName("webtab"); 11 | ui->setupUi(this); 12 | webview = new WebViewRS(); 13 | //QTextBrowser 14 | this->ui->verticalLayout->addWidget(webview,1); 15 | webview->show(); 16 | //QString loadfirst = "";//QDir::homePath(); 17 | 18 | //loadfirst.append("html/index.html"); 19 | //webview->setUrl(QUrl(loadfirst)); 20 | 21 | 22 | //jslog = new QTextBrowser(); 23 | //this->ui->verticalLayout->addWidget(jslog,1); 24 | //jslog->show(); 25 | QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); 26 | QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true); 27 | QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); 28 | QWebSettings::globalSettings()->setAttribute(QWebSettings::WebGLEnabled, true); 29 | QWebSettings::globalSettings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true); 30 | 31 | //connect(ui->testButton, SIGNAL(clicked()), this->webview, SLOT(reload())); 32 | connect(ui->testButton, SIGNAL(clicked()), this, SLOT(changeLocation())); 33 | 34 | 35 | connect(ui->lineEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); 36 | connect(webview, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); 37 | } 38 | 39 | WebTabContents::~WebTabContents() 40 | { 41 | delete ui; 42 | } 43 | 44 | void WebTabContents::changeLocation() 45 | { 46 | QUrl url = QUrl(ui->lineEdit->text()); 47 | webview->load(url); 48 | webview->setFocus(); 49 | } 50 | void WebTabContents::adjustLocation() 51 | { 52 | ui->lineEdit->setText(webview->url().toString()); 53 | } 54 | 55 | WebViewRS *WebTabContents::getWebView() 56 | { 57 | return webview; 58 | } 59 | -------------------------------------------------------------------------------- /interface/rsWebView.h: -------------------------------------------------------------------------------- 1 | /* this is a simple class to make it easy for any part of the plugin to call its services */ 2 | /**************************************************************** 3 | * RetroShare is distributed under the following license: 4 | * 5 | * Copyright (C) 2015 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 | * Boston, MA 02110-1301, USA. 21 | ****************************************************************/ 22 | 23 | // interface class for p3WebView service 24 | // 25 | 26 | #pragma once 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class RsWebView ; 35 | extern RsWebView *rsWebView; 36 | 37 | //TODO explain this const 38 | static const uint32_t CONFIG_TYPE_WebView_PLUGIN = 0xe001 ; 39 | 40 | class RsWebView 41 | { 42 | public: 43 | 44 | //not fully implemented 45 | virtual void ping_all() = 0; 46 | 47 | //broadcasts json packets with some text coords for chatting 48 | virtual void msg_all(std::string msg) = 0; 49 | 50 | //send data to a peer using your own serialisation 51 | virtual void raw_msg_peer(RsPeerId peerID, std::string msg) = 0; 52 | 53 | //convenience functions 54 | //virtual void str_msg_peer(RsPeerId peerID, QString strdata) = 0; 55 | //virtual void qvm_msg_peer(RsPeerId peerID, QVariantMap data) = 0; 56 | }; 57 | 58 | 59 | -------------------------------------------------------------------------------- /rshtml/js/Detector.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * @author mr.doob / http://mrdoob.com/ 4 | */ 5 | 6 | Detector = { 7 | 8 | canvas: !! window.CanvasRenderingContext2D, 9 | webgl: ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(), 10 | workers: !! window.Worker, 11 | fileapi: window.File && window.FileReader && window.FileList && window.Blob, 12 | 13 | getWebGLErrorMessage: function () { 14 | 15 | var element = document.createElement( 'div' ); 16 | element.id = 'webgl-error-message'; 17 | element.style.fontFamily = 'monospace'; 18 | element.style.fontSize = '13px'; 19 | element.style.fontWeight = 'normal'; 20 | element.style.textAlign = 'center'; 21 | element.style.background = '#fff'; 22 | element.style.color = '#000'; 23 | element.style.padding = '1.5em'; 24 | element.style.width = '400px'; 25 | element.style.margin = '5em auto 0'; 26 | 27 | if ( ! this.webgl ) { 28 | 29 | element.innerHTML = window.WebGLRenderingContext ? [ 30 | 'Your graphics card does not seem to support WebGL.
', 31 | 'Find out how to get it here.' 32 | ].join( '\n' ) : [ 33 | 'Your browser does not seem to support WebGL.
', 34 | 'Find out how to get it here.' 35 | ].join( '\n' ); 36 | 37 | } 38 | 39 | return element; 40 | 41 | }, 42 | 43 | addGetWebGLMessage: function ( parameters ) { 44 | 45 | var parent, id, element; 46 | 47 | parameters = parameters || {}; 48 | 49 | parent = parameters.parent !== undefined ? parameters.parent : document.body; 50 | id = parameters.id !== undefined ? parameters.id : 'oldie'; 51 | 52 | element = Detector.getWebGLErrorMessage(); 53 | element.id = id; 54 | 55 | parent.appendChild( element ); 56 | 57 | } 58 | 59 | }; 60 | -------------------------------------------------------------------------------- /rshtml/directchat.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | Direct Chat 8 | 9 | 47 | 48 | 49 | 50 |

51 | Back to index

52 |

53 | Chat: 54 |

55 | 57 | 58 | 59 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/xml/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeMirror: XML mode 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 24 | 25 |
26 |

XML mode

27 |
39 | 45 |

The XML mode supports two configuration parameters:

46 |
47 |
htmlMode (boolean)
48 |
This switches the mode to parse HTML instead of XML. This 49 | means attributes do not have to be quoted, and some elements 50 | (such as br) do not require a closing tag.
51 |
alignCDATA (boolean)
52 |
Setting this to true will force the opening tag of CDATA 53 | blocks to not be indented.
54 |
55 | 56 |

MIME types defined: application/xml, text/html.

57 |
58 | -------------------------------------------------------------------------------- /WebView.pro: -------------------------------------------------------------------------------- 1 | !include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri") 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4) { 4 | # Qt 5 5 | QT += widgets 6 | QT += webkitwidgets 7 | } 8 | 9 | QT += webkit 10 | QT += network 11 | exists($$[QMAKE_MKSPECS]/features/mobility.prf) { 12 | CONFIG += mobility 13 | } else { 14 | QT += multimedia 15 | } 16 | CONFIG += qt uic qrc resources 17 | MOBILITY = multimedia 18 | 19 | DEPENDPATH += ../../retroshare-gui/src/temp/ui ../../libretroshare/src 20 | INCLUDEPATH += ../../retroshare-gui/src/temp/ui ../../libretroshare/src 21 | 22 | #################################### Windows ##################################### 23 | 24 | linux-* { 25 | INCLUDEPATH += /usr/include 26 | LIBS += $$system(pkg-config --libs opencv) 27 | } 28 | 29 | win32 { 30 | LIBS_DIR = $$PWD/../../../libs 31 | LIBS += -L"$$LIBS_DIR/lib/opencv" 32 | 33 | OPENCV_VERSION = 249 34 | LIBS += -lopencv_core$$OPENCV_VERSION -lopencv_highgui$$OPENCV_VERSION -lopencv_imgproc$$OPENCV_VERSION -llibjpeg -llibtiff -llibpng -llibjasper -lIlmImf -lole32 -loleaut32 -luuid -lavicap32 -lavifil32 -lvfw32 -lz 35 | } 36 | 37 | QMAKE_CXXFLAGS *= -Wall 38 | 39 | SOURCES = WebViewPlugin.cpp \ 40 | services/p3WebView.cc \ 41 | services/rsWebViewItems.cc \ 42 | gui/WebViewMainpage.cpp \ 43 | gui/WebViewNotify.cpp \ 44 | gui/webenginepagepanel.cpp \ 45 | gui/webviewrs.cpp \ 46 | gui/webtabcontents.cpp \ 47 | gui/webbridgers.cpp \ 48 | gui/filedownloader.cpp 49 | 50 | HEADERS = WebViewPlugin.h \ 51 | services/p3WebView.h \ 52 | services/rsWebViewItems.h \ 53 | interface/rsWebView.h \ 54 | gui/WebViewMainpage.h \ 55 | gui/WebViewNotify.h \ 56 | gui/webenginepagepanel.h \ 57 | gui/webviewrs.h \ 58 | gui/webtabcontents.h \ 59 | gui/webbridgers.h \ 60 | gui/filedownloader.h 61 | 62 | #FORMS = gui/AudioInputConfig.ui 63 | 64 | TARGET = WebView 65 | 66 | RESOURCES = gui/WebView_images.qrc \ 67 | html_rc.qrc 68 | 69 | 70 | LIBS += -lspeex -lspeexdsp 71 | 72 | FORMS += \ 73 | gui/WebViewMainpage.ui \ 74 | gui/webenginepagepanel.ui \ 75 | gui/webtabcontents.ui 76 | -------------------------------------------------------------------------------- /rshtml/friends.html: -------------------------------------------------------------------------------- 1 | Index 2 | 3 | 4 | 5 | 6 | Back to Index
7 | 8 | All Friends: 9 |

10 | 11 | 12 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /gui/webbridgers.h: -------------------------------------------------------------------------------- 1 | #ifndef WEBBRIDGERS_H 2 | #define WEBBRIDGERS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | //class RsWebView; 13 | 14 | /*this class is passed to JS as "bridge"*/ 15 | class WebBridgeRS : public QObject 16 | { 17 | 18 | Q_OBJECT 19 | Q_CLASSINFO("serviceName", "bridge") 20 | public: 21 | explicit WebBridgeRS(QObject *parent = 0); 22 | void pushMsgToJs(QVariantMap message); 23 | //p3JsonRS *p3service; 24 | QMap avatars; 25 | 26 | //the public slots are exposed to JS 27 | public slots: 28 | 29 | #ifdef EMBPYTHON 30 | void runPython(QString text); 31 | void runPythonFile(QString fileName); 32 | #endif 33 | #ifdef BRIDGEGXS 34 | void initQ(); 35 | #endif 36 | QString getOwnId(); 37 | QString getDownloadDirectory(); 38 | QVariantMap searchKeywords(const QString& keywords, QVariantMap searchOptions); 39 | //QString processLink(QString url); 40 | void processLinks(QStringList urls); 41 | 42 | void broadcastMessage(QString msg); 43 | void sendMessage(QString peer, QString msg); 44 | QVariantMap getPeers(); 45 | QVariantMap downloadFile(QString qname, QString qhash, int qsize); 46 | void downloadURL(QString url); 47 | void broadcastToRS(QString msg); 48 | //QVariantList getPublicChatQueue(); 49 | 50 | QVariantMap fileDetails(QString qhash); 51 | void newTabAt(QString url); 52 | #ifdef BRIDGEGXS 53 | QVariantList getPostedList(); 54 | #endif 55 | QStringList getFriendList(); 56 | QStringList getGPGAllList(); 57 | QString getGPGId(QString inId); 58 | QStringList getOnlineList(); 59 | QVariantMap getPeerDetails(QString ssl_id); 60 | QString getPeerName(QString ssl_id); 61 | QPixmap getAvatarDetails(QString ssl_id); 62 | QStringList getDiscGPGFriends(QString gpg_id); 63 | void writeString(QString fname, QString data); 64 | private slots: 65 | void onUrlDownloaded(); 66 | void onDownloadComplete(QString hash); 67 | void gotTurtleSearchResult(qulonglong search_id,FileDetail file); 68 | private: 69 | 70 | void loadRequest(const TokenQueue *queue, const TokenRequest &req); 71 | signals: 72 | void msgPush(QVariantMap message); 73 | void urlDownloaded(QString path, QString url); 74 | void rsDownloaded(QVariantMap); 75 | void rsTurtleResult(QVariantMap); 76 | void newTabUrl(QString url); 77 | 78 | }; 79 | 80 | extern WebBridgeRS *eBridge; 81 | 82 | #endif // WEBBRIDGERS_H 83 | -------------------------------------------------------------------------------- /rshtml/js/Stats.js: -------------------------------------------------------------------------------- 1 | // stats.js r8 - http://github.com/mrdoob/stats.js 2 | var Stats=function(){var h,a,n=0,o=0,i=Date.now(),u=i,p=i,l=0,q=1E3,r=0,e,j,f,b=[[16,16,48],[0,255,255]],m=0,s=1E3,t=0,d,k,g,c=[[16,48,16],[0,255,0]];h=document.createElement("div");h.style.cursor="pointer";h.style.width="80px";h.style.opacity="0.9";h.style.zIndex="10001";h.addEventListener("mousedown",function(a){a.preventDefault();n=(n+1)%2;n==0?(e.style.display="block",d.style.display="none"):(e.style.display="none",d.style.display="block")},!1);e=document.createElement("div");e.style.textAlign= 3 | "left";e.style.lineHeight="1.2em";e.style.backgroundColor="rgb("+Math.floor(b[0][0]/2)+","+Math.floor(b[0][1]/2)+","+Math.floor(b[0][2]/2)+")";e.style.padding="0 0 3px 3px";h.appendChild(e);j=document.createElement("div");j.style.fontFamily="Helvetica, Arial, sans-serif";j.style.fontSize="9px";j.style.color="rgb("+b[1][0]+","+b[1][1]+","+b[1][2]+")";j.style.fontWeight="bold";j.innerHTML="FPS";e.appendChild(j);f=document.createElement("div");f.style.position="relative";f.style.width="74px";f.style.height= 4 | "30px";f.style.backgroundColor="rgb("+b[1][0]+","+b[1][1]+","+b[1][2]+")";for(e.appendChild(f);f.children.length<74;)a=document.createElement("span"),a.style.width="1px",a.style.height="30px",a.style.cssFloat="left",a.style.backgroundColor="rgb("+b[0][0]+","+b[0][1]+","+b[0][2]+")",f.appendChild(a);d=document.createElement("div");d.style.textAlign="left";d.style.lineHeight="1.2em";d.style.backgroundColor="rgb("+Math.floor(c[0][0]/2)+","+Math.floor(c[0][1]/2)+","+Math.floor(c[0][2]/2)+")";d.style.padding= 5 | "0 0 3px 3px";d.style.display="none";h.appendChild(d);k=document.createElement("div");k.style.fontFamily="Helvetica, Arial, sans-serif";k.style.fontSize="9px";k.style.color="rgb("+c[1][0]+","+c[1][1]+","+c[1][2]+")";k.style.fontWeight="bold";k.innerHTML="MS";d.appendChild(k);g=document.createElement("div");g.style.position="relative";g.style.width="74px";g.style.height="30px";g.style.backgroundColor="rgb("+c[1][0]+","+c[1][1]+","+c[1][2]+")";for(d.appendChild(g);g.children.length<74;)a=document.createElement("span"), 6 | a.style.width="1px",a.style.height=Math.random()*30+"px",a.style.cssFloat="left",a.style.backgroundColor="rgb("+c[0][0]+","+c[0][1]+","+c[0][2]+")",g.appendChild(a);return{domElement:h,update:function(){i=Date.now();m=i-u;s=Math.min(s,m);t=Math.max(t,m);k.textContent=m+" MS ("+s+"-"+t+")";var a=Math.min(30,30-m/200*30);g.appendChild(g.firstChild).style.height=a+"px";u=i;o++;if(i>p+1E3)l=Math.round(o*1E3/(i-p)),q=Math.min(q,l),r=Math.max(r,l),j.textContent=l+" FPS ("+q+"-"+r+")",a=Math.min(30,30-l/ 7 | 100*30),f.appendChild(f.firstChild).style.height=a+"px",p=i,o=0}}}; 8 | 9 | -------------------------------------------------------------------------------- /gui/WebViewMainpage.cpp: -------------------------------------------------------------------------------- 1 | #include "WebViewMainpage.h" 2 | #include "ui_WebViewMainpage.h" 3 | //#include "services/p3WebView.h" 4 | #include "interface/rsWebView.h" 5 | #include 6 | #include "webbridgers.h" 7 | 8 | //#include "webenginepagepanel.h" 9 | #include "webtabcontents.h" 10 | 11 | 12 | WebBridgeRS *eBridge = new WebBridgeRS(); 13 | WebViewMainpage::WebViewMainpage(QWidget *parent, WebViewNotify *notify) : 14 | MainPage(parent), 15 | mNotify(notify), 16 | ui(new Ui::WebViewMainpage) 17 | { 18 | ui->setupUi(this); 19 | 20 | connect(mNotify, SIGNAL(NeMsgArrived(RsPeerId,QString)), this , SLOT(NeMsgArrived(RsPeerId,QString))); 21 | //ui->tabWidget->addTab(new WebViewPagePanel(), "Home"); 22 | WebTabContents * wtc = new WebTabContents(this); 23 | wtc->getWebView()->setUrl(QUrl("qrc:/rshtml/index.html")); 24 | ui->tabWidget->addTab(wtc,QString("WSRS")); 25 | 26 | } 27 | /* 28 | * void WebScriptDialog::onNewTabUrl(QString url) 29 | { 30 | WebTabContents * wtc = new WebTabContents(this); 31 | wtc->getWebView()->setUrl(QUrl(url)); 32 | ui->webTabs->addTab(wtc,QString("WSRS")); 33 | connect( wtc->getWebView(), SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString)) ); 34 | connect( wtc->getWebView(), SIGNAL(requestTabForHash(QString)), this, SLOT(onNewRsTab(QString)) ); 35 | } 36 | */ 37 | 38 | WebViewMainpage::~WebViewMainpage() 39 | { 40 | delete ui; 41 | } 42 | 43 | 44 | void WebViewMainpage::on_pingAllButton_clicked() 45 | { 46 | rsWebView->ping_all(); 47 | NeMsgArrived(rsPeers->getOwnId(),"ping"); 48 | } 49 | 50 | 51 | void WebViewMainpage::NeMsgArrived(const RsPeerId &peer_id, QString str) 52 | { 53 | /*QJsonDocument jdoc = QJsonDocument::fromJson(str.toUtf8()); 54 | QVariantMap vmap = jdoc.toVariant().toMap(); 55 | std::cout << "GUI got Packet from: " << peer_id; 56 | std::cout << " saying " << str.toStdString(); 57 | std::cout << std::endl; 58 | QString type = vmap.value("type").toString(); 59 | if (type == "chat"){ 60 | QString output = QString::fromStdString(rsPeers->getPeerName(peer_id)); 61 | output+=": "; 62 | output+=vmap.value("message").toString(); 63 | //ui->listWidget->addItem(output); 64 | }else{ 65 | QString output = QString::fromStdString(rsPeers->getPeerName(peer_id)); 66 | output+=": "; 67 | output+=str; 68 | //ui->listWidget->addItem(output); 69 | } 70 | 71 | { 72 | QString output = QString::fromStdString(rsPeers->getPeerName(peer_id)); 73 | output+=": "; 74 | output+=str; 75 | //ui->netLogWidget->addItem(output); 76 | }*/ 77 | } 78 | 79 | void WebViewMainpage::on_broadcastButton_clicked() 80 | { 81 | /*rsWebView->msg_all(ui->msgInput->text().toStdString()); 82 | NeMsgArrived(rsPeers->getOwnId(),ui->msgInput->text()); 83 | ui->msgInput->clear();*/ 84 | } 85 | -------------------------------------------------------------------------------- /rshtml/search2.html: -------------------------------------------------------------------------------- 1 | Multi-Search 2 | 3 | 4 | 63 | 64 | 65 | back to index
66 | 67 | 68 | searchLimit 69 |

70 | 71 | 72 | -------------------------------------------------------------------------------- /rshtml/nicehtml/index.html: -------------------------------------------------------------------------------- 1 | 2 | nope 3 | 4 | 5 |
6 | 11 | 19 |
20 |
21 |
22 | 28 |
29 |
30 |

31 | Page heading 32 |

33 |

34 | Lorem ipsum dolor sit amet consect etuer adipi scing elit sed diam nonummy nibh euismod tinunt ut laoreet dolore magna aliquam erat volut. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. 35 |

36 |

37 | Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. 38 |

39 |

40 | Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. 41 |

42 |
43 |
44 |

45 | Aside heading 46 |

47 |

48 | Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan. 49 |

50 |
51 | 54 |
55 |
56 |
57 | 58 | 59 | -------------------------------------------------------------------------------- /WebViewPlugin.h: -------------------------------------------------------------------------------- 1 | /* this is the central part of the plugin */ 2 | /**************************************************************** 3 | * RetroShare is distributed under the following license: 4 | * 5 | * Copyright (C) 2015 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 | * Boston, MA 02110-1301, USA. 21 | ****************************************************************/ 22 | #pragma once 23 | 24 | /*WebView*/ 25 | #include "services/p3WebView.h" 26 | 27 | /*libretroshare"*/ 28 | #include 29 | 30 | #include "gui/WebViewMainpage.h" 31 | 32 | class WebViewGUIHandler ; 33 | class WebViewNotify ; 34 | 35 | class WebViewPlugin: public RsPlugin 36 | { 37 | public: 38 | WebViewPlugin() ; 39 | virtual ~WebViewPlugin() {} 40 | 41 | virtual p3Service *p3_service() const ; 42 | virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_WebView_PLUGIN ; } 43 | //virtual ConfigPage *qt_config_page() const ; 44 | virtual QDialog *qt_about_page() const ; 45 | //virtual ChatWidgetHolder *qt_get_chat_widget_holder(ChatWidget *chatWidget) const ; 46 | 47 | virtual QIcon *qt_icon() const; 48 | virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode, const QString& externalDir) const; 49 | virtual void qt_sound_events(SoundEvents &events) const; 50 | 51 | virtual void getPluginVersion(int& major, int& minor, int &build, int& svn_rev) const ; 52 | virtual void setPlugInHandler(RsPluginHandler *pgHandler); 53 | 54 | virtual std::string configurationFileName() const { return "WebView.cfg" ; } 55 | 56 | virtual std::string getShortPluginDescription() const ; 57 | virtual std::string getPluginName() const; 58 | virtual void setInterfaces(RsPlugInInterfaces& interfaces); 59 | 60 | //================================== RsPlugin Notify ==================================// 61 | //virtual ToasterNotify *qt_toasterNotify(); 62 | 63 | virtual MainPage *qt_page() const ; 64 | 65 | private: 66 | mutable p3WebView *mWebView ; 67 | mutable RsPluginHandler *mPlugInHandler; 68 | mutable RsPeers* mPeers; 69 | mutable ConfigPage *config_page ; 70 | mutable QIcon *mIcon; 71 | mutable MainPage* mainpage ; 72 | 73 | WebViewNotify *mWebViewNotify ; 74 | WebViewGUIHandler *mWebViewGUIHandler ; 75 | }; 76 | 77 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/css/scss_test.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var mode = CodeMirror.getMode({tabSize: 1}, "text/x-scss"); 3 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); } 4 | function IT(name) { test.indentation(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); } 5 | 6 | MT('url_with_quotation', 7 | "[tag foo] { [property background][operator :][string-2 url]([string test.jpg]) }"); 8 | 9 | MT('url_with_double_quotes', 10 | "[tag foo] { [property background][operator :][string-2 url]([string \"test.jpg\"]) }"); 11 | 12 | MT('url_with_single_quotes', 13 | "[tag foo] { [property background][operator :][string-2 url]([string \'test.jpg\']) }"); 14 | 15 | MT('string', 16 | "[def @import] [string \"compass/css3\"]"); 17 | 18 | MT('important_keyword', 19 | "[tag foo] { [property background][operator :][string-2 url]([string \'test.jpg\']) [keyword !important] }"); 20 | 21 | MT('variable', 22 | "[variable-2 $blue][operator :][atom #333]"); 23 | 24 | MT('variable_as_attribute', 25 | "[tag foo] { [property color][operator :][variable-2 $blue] }"); 26 | 27 | MT('numbers', 28 | "[tag foo] { [property padding][operator :][number 10px] [number 10] [number 10em] [number 8in] }"); 29 | 30 | MT('number_percentage', 31 | "[tag foo] { [property width][operator :][number 80%] }"); 32 | 33 | MT('selector', 34 | "[builtin #hello][qualifier .world]{}"); 35 | 36 | MT('singleline_comment', 37 | "[comment // this is a comment]"); 38 | 39 | MT('multiline_comment', 40 | "[comment /*foobar*/]"); 41 | 42 | MT('attribute_with_hyphen', 43 | "[tag foo] { [property font-size][operator :][number 10px] }"); 44 | 45 | MT('string_after_attribute', 46 | "[tag foo] { [property content][operator :][string \"::\"] }"); 47 | 48 | MT('directives', 49 | "[def @include] [qualifier .mixin]"); 50 | 51 | MT('basic_structure', 52 | "[tag p] { [property background][operator :][keyword red]; }"); 53 | 54 | MT('nested_structure', 55 | "[tag p] { [tag a] { [property color][operator :][keyword red]; } }"); 56 | 57 | MT('mixin', 58 | "[def @mixin] [tag table-base] {}"); 59 | 60 | MT('number_without_semicolon', 61 | "[tag p] {[property width][operator :][number 12]}", 62 | "[tag a] {[property color][operator :][keyword red];}"); 63 | 64 | MT('atom_in_nested_block', 65 | "[tag p] { [tag a] { [property color][operator :][atom #000]; } }"); 66 | 67 | MT('interpolation_in_property', 68 | "[tag foo] { [operator #{][variable-2 $hello][operator }:][number 2]; }"); 69 | 70 | MT('interpolation_in_selector', 71 | "[tag foo][operator #{][variable-2 $hello][operator }] { [property color][operator :][atom #000]; }"); 72 | 73 | MT('interpolation_error', 74 | "[tag foo][operator #{][error foo][operator }] { [property color][operator :][atom #000]; }"); 75 | 76 | MT("divide_operator", 77 | "[tag foo] { [property width][operator :][number 4] [operator /] [number 2] }"); 78 | 79 | MT('nested_structure_with_id_selector', 80 | "[tag p] { [builtin #hello] { [property color][operator :][keyword red]; } }"); 81 | 82 | IT('mixin', 83 | "@mixin container[1 (][2 $a: 10][1 , ][2 $b: 10][1 , ][2 $c: 10]) [1 {]}"); 84 | })(); 85 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/htmlmixed/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeMirror: HTML mixed mode 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 28 | 29 |
30 |

HTML mixed mode

31 |
55 | 67 | 68 |

The HTML mixed mode depends on the XML, JavaScript, and CSS modes.

69 | 70 |

It takes an optional mode configuration 71 | option, scriptTypes, which can be used to add custom 72 | behavior for specific <script type="..."> tags. If 73 | given, it should hold an array of {matches, mode} 74 | objects, where matches is a string or regexp that 75 | matches the script type, and mode is 76 | either null, for script types that should stay in 77 | HTML mode, or a mode 78 | spec corresponding to the mode that should be used for the 79 | script.

80 | 81 |

MIME types defined: text/html 82 | (redefined, only takes effect if you load this parser after the 83 | XML parser).

84 | 85 |
86 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/css/scss.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeMirror: SCSS mode 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 24 | 25 |
26 |

SCSS mode

27 |
145 | 152 | 153 |

MIME types defined: text/scss.

154 | 155 |

Parsing/Highlighting Tests: normal, verbose.

156 | 157 |
158 | -------------------------------------------------------------------------------- /rshtml/viewforum.html: -------------------------------------------------------------------------------- 1 | Index 2 | 3 | 4 | 5 | Back to Index
6 | 7 |
8 | Messages: 9 |

10 | 11 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /rshtml/js/THREEx.FullScreen.js: -------------------------------------------------------------------------------- 1 | // This THREEx helper makes it easy to handle the fullscreen API 2 | // * it hides the prefix for each browser 3 | // * it hides the little discrepencies of the various vendor API 4 | // * at the time of this writing (nov 2011) it is available in 5 | // [firefox nightly](http://blog.pearce.org.nz/2011/11/firefoxs-html-full-screen-api-enabled.html), 6 | // [webkit nightly](http://peter.sh/2011/01/javascript-full-screen-api-navigation-timing-and-repeating-css-gradients/) and 7 | // [chrome stable](http://updates.html5rocks.com/2011/10/Let-Your-Content-Do-the-Talking-Fullscreen-API). 8 | 9 | // # Code 10 | 11 | /** @namespace */ 12 | var THREEx = THREEx || {}; 13 | THREEx.FullScreen = THREEx.FullScreen || {}; 14 | 15 | /** 16 | * test if it is possible to have fullscreen 17 | * 18 | * @returns {Boolean} true if fullscreen API is available, false otherwise 19 | */ 20 | THREEx.FullScreen.available = function() 21 | { 22 | return this._hasWebkitFullScreen || this._hasMozFullScreen; 23 | } 24 | 25 | /** 26 | * test if fullscreen is currently activated 27 | * 28 | * @returns {Boolean} true if fullscreen is currently activated, false otherwise 29 | */ 30 | THREEx.FullScreen.activated = function() 31 | { 32 | if( this._hasWebkitFullScreen ){ 33 | return document.webkitIsFullScreen; 34 | }else if( this._hasMozFullScreen ){ 35 | return document.mozFullScreen; 36 | }else{ 37 | console.assert(false); 38 | } 39 | } 40 | 41 | /** 42 | * Request fullscreen on a given element 43 | * @param {DomElement} element to make fullscreen. optional. default to document.body 44 | */ 45 | THREEx.FullScreen.request = function(element) 46 | { 47 | element = element || document.body; 48 | if( this._hasWebkitFullScreen ){ 49 | element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); 50 | }else if( this._hasMozFullScreen ){ 51 | element.mozRequestFullScreen(); 52 | }else{ 53 | console.assert(false); 54 | } 55 | } 56 | 57 | /** 58 | * Cancel fullscreen 59 | */ 60 | THREEx.FullScreen.cancel = function() 61 | { 62 | if( this._hasWebkitFullScreen ){ 63 | document.webkitCancelFullScreen(); 64 | }else if( this._hasMozFullScreen ){ 65 | document.mozCancelFullScreen(); 66 | }else{ 67 | console.assert(false); 68 | } 69 | } 70 | 71 | // internal functions to know which fullscreen API implementation is available 72 | THREEx.FullScreen._hasWebkitFullScreen = 'webkitCancelFullScreen' in document ? true : false; 73 | THREEx.FullScreen._hasMozFullScreen = 'mozCancelFullScreen' in document ? true : false; 74 | 75 | /** 76 | * Bind a key to renderer screenshot 77 | * usage: THREEx.FullScreen.bindKey({ charCode : 'a'.charCodeAt(0) }); 78 | */ 79 | THREEx.FullScreen.bindKey = function(opts){ 80 | opts = opts || {}; 81 | var charCode = opts.charCode || 'f'.charCodeAt(0); 82 | var dblclick = opts.dblclick !== undefined ? opts.dblclick : false; 83 | var element = opts.element 84 | 85 | var toggle = function(){ 86 | if( THREEx.FullScreen.activated() ){ 87 | THREEx.FullScreen.cancel(); 88 | }else{ 89 | THREEx.FullScreen.request(element); 90 | } 91 | } 92 | 93 | var onKeyPress = function(event){ 94 | if( event.which !== charCode ) return; 95 | toggle(); 96 | }.bind(this); 97 | 98 | document.addEventListener('keypress', onKeyPress, false); 99 | 100 | dblclick && document.addEventListener('dblclick', toggle, false); 101 | 102 | return { 103 | unbind : function(){ 104 | document.removeEventListener('keypress', onKeyPress, false); 105 | dblclick && document.removeEventListener('dblclick', toggle, false); 106 | } 107 | }; 108 | } 109 | -------------------------------------------------------------------------------- /rshtml/js/THREEx.KeyboardState.js: -------------------------------------------------------------------------------- 1 | // THREEx.KeyboardState.js keep the current state of the keyboard. 2 | // It is possible to query it at any time. No need of an event. 3 | // This is particularly convenient in loop driven case, like in 4 | // 3D demos or games. 5 | // 6 | // # Usage 7 | // 8 | // **Step 1**: Create the object 9 | // 10 | // ```var keyboard = new THREEx.KeyboardState();``` 11 | // 12 | // **Step 2**: Query the keyboard state 13 | // 14 | // This will return true if shift and A are pressed, false otherwise 15 | // 16 | // ```keyboard.pressed("shift+A")``` 17 | // 18 | // **Step 3**: Stop listening to the keyboard 19 | // 20 | // ```keyboard.destroy()``` 21 | // 22 | // NOTE: this library may be nice as standaline. independant from three.js 23 | // - rename it keyboardForGame 24 | // 25 | // # Code 26 | // 27 | 28 | /** @namespace */ 29 | var THREEx = THREEx || {}; 30 | 31 | /** 32 | * - NOTE: it would be quite easy to push event-driven too 33 | * - microevent.js for events handling 34 | * - in this._onkeyChange, generate a string from the DOM event 35 | * - use this as event name 36 | */ 37 | THREEx.KeyboardState = function() 38 | { 39 | // to store the current state 40 | this.keyCodes = {}; 41 | this.modifiers = {}; 42 | 43 | // create callback to bind/unbind keyboard events 44 | var self = this; 45 | this._onKeyDown = function(event){ self._onKeyChange(event, true); }; 46 | this._onKeyUp = function(event){ self._onKeyChange(event, false);}; 47 | 48 | // bind keyEvents 49 | document.addEventListener("keydown", this._onKeyDown, false); 50 | document.addEventListener("keyup", this._onKeyUp, false); 51 | } 52 | 53 | /** 54 | * To stop listening of the keyboard events 55 | */ 56 | THREEx.KeyboardState.prototype.destroy = function() 57 | { 58 | // unbind keyEvents 59 | document.removeEventListener("keydown", this._onKeyDown, false); 60 | document.removeEventListener("keyup", this._onKeyUp, false); 61 | } 62 | 63 | THREEx.KeyboardState.MODIFIERS = ['shift', 'ctrl', 'alt', 'meta']; 64 | THREEx.KeyboardState.ALIAS = { 65 | 'left' : 37, 66 | 'up' : 38, 67 | 'right' : 39, 68 | 'down' : 40, 69 | 'space' : 32, 70 | 'pageup' : 33, 71 | 'pagedown' : 34, 72 | 'tab' : 9 73 | }; 74 | 75 | /** 76 | * to process the keyboard dom event 77 | */ 78 | THREEx.KeyboardState.prototype._onKeyChange = function(event, pressed) 79 | { 80 | // log to debug 81 | //console.log("onKeyChange", event, pressed, event.keyCode, event.shiftKey, event.ctrlKey, event.altKey, event.metaKey) 82 | 83 | // update this.keyCodes 84 | var keyCode = event.keyCode; 85 | this.keyCodes[keyCode] = pressed; 86 | 87 | // update this.modifiers 88 | this.modifiers['shift']= event.shiftKey; 89 | this.modifiers['ctrl'] = event.ctrlKey; 90 | this.modifiers['alt'] = event.altKey; 91 | this.modifiers['meta'] = event.metaKey; 92 | } 93 | 94 | /** 95 | * query keyboard state to know if a key is pressed of not 96 | * 97 | * @param {String} keyDesc the description of the key. format : modifiers+key e.g shift+A 98 | * @returns {Boolean} true if the key is pressed, false otherwise 99 | */ 100 | THREEx.KeyboardState.prototype.pressed = function(keyDesc) 101 | { 102 | var keys = keyDesc.split("+"); 103 | for(var i = 0; i < keys.length; i++){ 104 | var key = keys[i]; 105 | var pressed; 106 | if( THREEx.KeyboardState.MODIFIERS.indexOf( key ) !== -1 ){ 107 | pressed = this.modifiers[key]; 108 | }else if( Object.keys(THREEx.KeyboardState.ALIAS).indexOf( key ) != -1 ){ 109 | pressed = this.keyCodes[ THREEx.KeyboardState.ALIAS[key] ]; 110 | }else { 111 | pressed = this.keyCodes[key.toUpperCase().charCodeAt(0)] 112 | } 113 | if( !pressed) return false; 114 | }; 115 | return true; 116 | } 117 | -------------------------------------------------------------------------------- /services/p3WebView.h: -------------------------------------------------------------------------------- 1 | /* this handles the networking service of this plugin */ 2 | /**************************************************************** 3 | * RetroShare is distributed under the following license: 4 | * 5 | * Copyright (C) 2015 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 | * Boston, MA 02110-1301, USA. 21 | ****************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "services/rsWebViewItems.h" 30 | #include "services/p3service.h" 31 | #include "serialiser/rstlvbase.h" 32 | #include "serialiser/rsconfigitems.h" 33 | #include "plugins/rspqiservice.h" 34 | #include 35 | 36 | class p3LinkMgr; 37 | class WebViewNotify ; 38 | 39 | 40 | 41 | //!The RS VoIP Test service. 42 | /** 43 | * 44 | * This is only used to test Latency for the moment. 45 | */ 46 | 47 | class p3WebView: public RsPQIService, public RsWebView 48 | // Maybe we inherit from these later - but not needed for now. 49 | //, public p3Config, public pqiMonitor 50 | { 51 | public: 52 | p3WebView(RsPluginHandler *cm,WebViewNotify *); 53 | 54 | /***** overloaded from rsWebView *****/ 55 | 56 | 57 | /***** overloaded from p3Service *****/ 58 | /*! 59 | * This retrieves all chat msg items and also (important!) 60 | * processes chat-status items that are in service item queue. chat msg item requests are also processed and not returned 61 | * (important! also) notifications sent to notify base on receipt avatar, immediate status and custom status 62 | * : notifyCustomState, notifyChatStatus, notifyPeerHasNewAvatar 63 | * @see NotifyBase 64 | */ 65 | virtual int tick(); 66 | virtual int status(); 67 | virtual bool recvItem(RsItem *item); 68 | 69 | /*************** pqiMonitor callback ***********************/ 70 | //virtual void statusChange(const std::list &plist); 71 | 72 | 73 | /************* from p3Config *******************/ 74 | virtual RsSerialiser *setupSerialiser() ; 75 | 76 | /*! 77 | * chat msg items and custom status are saved 78 | */ 79 | virtual bool saveList(bool& cleanup, std::list&) ; 80 | virtual bool loadList(std::list& load) ; 81 | virtual std::string configurationFileName() const { return "WebView.cfg" ; } 82 | 83 | virtual RsServiceInfo getServiceInfo() ; 84 | 85 | void ping_all(); 86 | 87 | void msg_all(std::string msg); 88 | void str_msg_peer(RsPeerId peerID, QString strdata); 89 | void raw_msg_peer(RsPeerId peerID, std::string msg); 90 | void qvm_msg_peer(RsPeerId peerID, QVariantMap data); 91 | private: 92 | 93 | 94 | 95 | void handleData(RsWebViewDataItem*) ; 96 | 97 | RsMutex mWebViewMtx; 98 | 99 | 100 | static RsTlvKeyValue push_int_value(const std::string& key,int value) ; 101 | static int pop_int_value(const std::string& s) ; 102 | 103 | 104 | RsServiceControl *mServiceControl; 105 | WebViewNotify *mNotify ; 106 | 107 | }; 108 | -------------------------------------------------------------------------------- /rshtml/localstorage.html: -------------------------------------------------------------------------------- 1 | Notes 2 | 3 | 4 | 5 | 19 | 20 | 21 |

Local Notes - back to index

22 | 23 | hide source? 24 | 25 | 26 |
27 |
28 |
29 |

30 | Rich Text (editable?) 31 |

32 | 33 | 34 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /html_rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | rshtml/ace/ace.js 4 | rshtml/ace/mode-html.js 5 | rshtml/ace/mode-javascript.js 6 | rshtml/audio/receive.wav 7 | rshtml/codemirror/mode/css/css.js 8 | rshtml/codemirror/mode/css/index.html 9 | rshtml/codemirror/mode/css/scss.html 10 | rshtml/codemirror/mode/css/scss_test.js 11 | rshtml/codemirror/mode/css/test.js 12 | rshtml/codemirror/mode/htmlmixed/htmlmixed.js 13 | rshtml/codemirror/mode/htmlmixed/index.html 14 | rshtml/codemirror/mode/javascript/index.html 15 | rshtml/codemirror/mode/javascript/javascript.js 16 | rshtml/codemirror/mode/javascript/test.js 17 | rshtml/codemirror/mode/javascript/typescript.html 18 | rshtml/codemirror/mode/xml/index.html 19 | rshtml/codemirror/mode/xml/xml.js 20 | rshtml/codemirror/codemirror.css 21 | rshtml/codemirror/codemirror.js 22 | rshtml/d3/d3.js 23 | rshtml/d3/d3.layout.js 24 | rshtml/ivank/asphalt.jpg 25 | rshtml/ivank/car.png 26 | rshtml/ivank/ivank.js 27 | rshtml/ivank/kevents.html 28 | rshtml/js/controls/OrbitControls.js 29 | rshtml/js/controls/TransformControls.js 30 | rshtml/js/Detector.js 31 | rshtml/js/OrbitControls.js 32 | rshtml/js/SceneExporter.js 33 | rshtml/js/Stats.js 34 | rshtml/js/Three.js 35 | rshtml/js/THREEx.FullScreen.js 36 | rshtml/js/THREEx.KeyboardState.js 37 | rshtml/js/THREEx.WindowResize.js 38 | rshtml/nicehtml/index.html 39 | rshtml/nicehtml/style.css 40 | rshtml/3dscenemap.html 41 | rshtml/acetest.html 42 | rshtml/broadcastchat.html 43 | rshtml/chattest.html 44 | rshtml/cmtest.html 45 | rshtml/ct.css 46 | rshtml/d3.v3.min.js 47 | rshtml/directchat.html 48 | rshtml/downloadurl.html 49 | rshtml/extimgtest.html 50 | rshtml/fdgraph.html 51 | rshtml/flare.json 52 | rshtml/friends.html 53 | rshtml/helvetiker_regular.typeface.js 54 | rshtml/improvedbroadcastchat.html 55 | rshtml/index.html 56 | rshtml/interactiveparticles.html 57 | rshtml/libsha512.js 58 | rshtml/listforums.html 59 | rshtml/loading.html 60 | rshtml/localstorage.html 61 | rshtml/microblog.html 62 | rshtml/phystest.html 63 | rshtml/phystest2.html 64 | rshtml/preview.html 65 | rshtml/search.html 66 | rshtml/search2.html 67 | rshtml/search3.html 68 | rshtml/select.html 69 | rshtml/speech.js 70 | rshtml/style.css 71 | rshtml/term_tree.js 72 | rshtml/Texture-From-Canvas.html 73 | rshtml/three.js 74 | rshtml/three.min.js 75 | rshtml/tree.html 76 | rshtml/viewforum.html 77 | rshtml/worker-javascript.js 78 | rshtml/zepto.min.js 79 | 80 | 81 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/javascript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeMirror: JavaScript mode 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 27 | 28 |
29 |

JavaScript mode

30 | 31 | 32 |
81 | 82 | 90 | 91 |

92 | JavaScript mode supports a two configuration 93 | options: 94 |

    95 |
  • json which will set the mode to expect JSON 96 | data rather than a JavaScript program.
  • 97 |
  • typescript which will activate additional 98 | syntax highlighting and some other things for TypeScript code 99 | (demo).
  • 100 |
  • statementIndent which (given a number) will 101 | determine the amount of indentation to use for statements 102 | continued on a new line.
  • 103 |
104 |

105 | 106 |

MIME types defined: text/javascript, application/json, text/typescript, application/typescript.

107 |
108 | -------------------------------------------------------------------------------- /rshtml/ivank/kevents.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ivank netcar 5 | 6 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /gui/webviewrs.cpp: -------------------------------------------------------------------------------- 1 | #include "webviewrs.h" 2 | #include 3 | #include 4 | #include "webbridgers.h" 5 | #include "gui/RetroShareLink.h" 6 | #include "gui/notifyqt.h" 7 | #include "retroshare/rsfiles.h" 8 | 9 | WebViewRS::WebViewRS(QWidget *parent) : 10 | QWebView(parent) 11 | { 12 | connect( this->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared()) ); 13 | this->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); 14 | connect( this->page(), SIGNAL(linkClicked(const QUrl & )), this, SLOT(onLinkClicked(const QUrl & )) ); 15 | settings()->enablePersistentStorage(); 16 | 17 | connect(NotifyQt::getInstance(), SIGNAL(downloadComplete(QString)), this, SLOT(onDownloadComplete(QString))); 18 | 19 | 20 | } 21 | WebViewRS::~WebViewRS() 22 | { 23 | //this->close(); 24 | } 25 | void WebViewRS::onDownloadComplete(QString hash){ 26 | if (hash == hashque){ 27 | 28 | FileInfo fi; 29 | // look up path 30 | if (rsFiles->alreadyHaveFile(RsFileHash(hash.toStdString()), fi)){ 31 | QString qpath(fi.path.c_str()); 32 | QString name(fi.fname.c_str()); 33 | if(!qpath.endsWith(name)){ 34 | qpath.append("/"); 35 | qpath.append(name); 36 | } 37 | QUrl newurl(qpath); 38 | this->setUrl(newurl); 39 | return; 40 | } 41 | } 42 | } 43 | 44 | void WebViewRS::onLinkClicked(const QUrl & url){ 45 | std::cout << "processing webkut url: " << url.toString().toStdString().c_str() << std::endl; 46 | if(url.toString().startsWith("retroshare")){ 47 | //retroshare://file?name=Distro_guide.png&size=946336&hash=68282a3813fa284ab3c997c9702599b44c6db568 48 | RetroShareLink rsl(url); 49 | if (rsl.name().endsWith(".png") || rsl.name().endsWith(".gif") || rsl.name().endsWith(".jpg") || rsl.name().endsWith(".txt") || 50 | rsl.name().endsWith(".html") || rsl.name().endsWith(".htm") || rsl.name().endsWith(".mp3")){ 51 | loadRSFile(rsl.name(), rsl.hash(), rsl.size()); 52 | return; 53 | } 54 | QStringList urls; 55 | urls.push_back(url.toString()); 56 | RetroShareLink::process(urls, RetroShareLink::TYPE_UNKNOWN, RSLINK_PROCESS_NOTIFY_ALL); 57 | } else { 58 | this->setUrl(url); 59 | } 60 | } 61 | 62 | void WebViewRS::loadRSFile(QString qname, QString qhash, int qsize){ 63 | 64 | FileInfo fi; 65 | //look up path 66 | if (rsFiles->alreadyHaveFile(RsFileHash(qhash.toStdString()), fi)){ 67 | QString qpath(fi.path.c_str()); 68 | QString name(fi.fname.c_str()); 69 | if(!qpath.endsWith(name)){ 70 | qpath.append("/"); 71 | qpath.append(name); 72 | } 73 | QUrl newurl(qpath); 74 | this->setUrl(newurl); 75 | return; 76 | } 77 | //hashque = qhash; 78 | emit requestTabForHash(qhash); 79 | // Get a list of available direct sources, in case the file is browsable only. 80 | // 81 | FileInfo finfo ; 82 | rsFiles->FileDetails(RsFileHash(qhash.toStdString()), RS_FILE_HINTS_REMOTE, finfo) ; 83 | 84 | std::list srcIds; 85 | for(std::list::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it) 86 | { 87 | #ifdef DEBUG_RSLINK 88 | std::cerr << " adding peerid " << (*it).peerId << std::endl ; 89 | #endif 90 | srcIds.push_back((*it).peerId) ; 91 | } 92 | 93 | if (rsFiles->FileRequest(qname.toStdString(), RsFileHash(qhash.toStdString()), qsize, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) { 94 | } else { 95 | } 96 | } 97 | 98 | void WebViewRS::onJavaScriptWindowObjectCleared() 99 | { 100 | QWebFrame *frame = this->page()->mainFrame(); 101 | //frame->setZoomFactor(4); 102 | frame->addToJavaScriptWindowObject("webview", this); 103 | frame->addToJavaScriptWindowObject("bridge", eBridge); 104 | } 105 | 106 | 107 | void WebViewRS::go2page(QString url) 108 | { 109 | this->setUrl(QUrl(url)); 110 | 111 | } 112 | 113 | void WebViewRS::onChange() 114 | { 115 | this->setUrl(QUrl("canvas_interactive_particles.html"));// << "Browser::onChange()"; 116 | qDebug() << "Browser::onChange()"; 117 | } 118 | 119 | void WebViewRS::setHashQue(QString hash) 120 | { 121 | hashque = hash; 122 | } 123 | -------------------------------------------------------------------------------- /services/rsWebViewItems.h: -------------------------------------------------------------------------------- 1 | /* this describes the datatypes sent over the network, and how to (de)serialise them */ 2 | /**************************************************************** 3 | * RetroShare is distributed under the following license: 4 | * 5 | * Copyright (C) 2015 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 | * Boston, MA 02110-1301, USA. 21 | ****************************************************************/ 22 | 23 | #pragma once 24 | 25 | /* 26 | * libretroshare/src/serialiser: rsWebViewItems.h 27 | * 28 | * RetroShare Serialiser. 29 | * 30 | * Copyright 2011 by Robert Fernie. 31 | * 32 | * This library is free software; you can redistribute it and/or 33 | * modify it under the terms of the GNU Library General Public 34 | * License Version 2 as published by the Free Software Foundation. 35 | * 36 | * This library is distributed in the hope that it will be useful, 37 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 38 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 39 | * Library General Public License for more details. 40 | * 41 | * You should have received a copy of the GNU Library General Public 42 | * License along with this library; if not, write to the Free Software 43 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 44 | * USA. 45 | * 46 | * Please report all bugs and problems to "retroshare@lunamutt.com". 47 | * 48 | */ 49 | 50 | #include 51 | 52 | #include "serialiser/rsserviceids.h" 53 | #include "serialiser/rsserial.h" 54 | 55 | /**************************************************************************/ 56 | 57 | const uint16_t RS_SERVICE_TYPE_WebView_PLUGIN = 0x3eb; 58 | 59 | const uint8_t RS_PKT_SUBTYPE_WebView_DATA = 0x01; 60 | 61 | const uint8_t QOS_PRIORITY_RS_WebView = 9 ; 62 | 63 | 64 | class RsWebViewItem: public RsItem 65 | { 66 | public: 67 | RsWebViewItem(uint8_t WebView_subtype) 68 | : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_WebView_PLUGIN,WebView_subtype) 69 | { 70 | setPriorityLevel(QOS_PRIORITY_RS_WebView) ; 71 | } 72 | 73 | virtual ~RsWebViewItem() {}; 74 | virtual void clear() {}; 75 | virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0 ; 76 | 77 | virtual bool serialise(void *data,uint32_t& size) = 0 ; // Isn't it better that items can serialise themselves ? 78 | virtual uint32_t serial_size() const = 0 ; // deserialise is handled using a constructor 79 | }; 80 | 81 | 82 | class RsWebViewDataItem: public RsWebViewItem 83 | { 84 | public: 85 | RsWebViewDataItem() :RsWebViewItem(RS_PKT_SUBTYPE_WebView_DATA) {} 86 | RsWebViewDataItem(void *data,uint32_t size) ; // de-serialization 87 | 88 | virtual bool serialise(void *data,uint32_t& size) ; 89 | virtual uint32_t serial_size() const ; 90 | 91 | virtual ~RsWebViewDataItem() 92 | { 93 | } 94 | virtual std::ostream& print(std::ostream &out, uint16_t indent = 0); 95 | 96 | uint32_t flags ; 97 | uint32_t data_size ; 98 | std::string m_msg; 99 | }; 100 | 101 | 102 | class RsWebViewSerialiser: public RsSerialType 103 | { 104 | public: 105 | RsWebViewSerialiser() 106 | :RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_WebView_PLUGIN) 107 | { 108 | } 109 | virtual ~RsWebViewSerialiser() {} 110 | 111 | virtual uint32_t size (RsItem *item) 112 | { 113 | return dynamic_cast(item)->serial_size() ; 114 | } 115 | 116 | virtual bool serialise (RsItem *item, void *data, uint32_t *size) 117 | { 118 | return dynamic_cast(item)->serialise(data,*size) ; 119 | } 120 | virtual RsItem *deserialise(void *data, uint32_t *size); 121 | }; 122 | 123 | /**************************************************************************/ 124 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/htmlmixed/htmlmixed.js: -------------------------------------------------------------------------------- 1 | CodeMirror.defineMode("htmlmixed", function(config, parserConfig) { 2 | var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true}); 3 | var cssMode = CodeMirror.getMode(config, "css"); 4 | 5 | var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes; 6 | scriptTypes.push({matches: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, 7 | mode: CodeMirror.getMode(config, "javascript")}); 8 | if (scriptTypesConf) for (var i = 0; i < scriptTypesConf.length; ++i) { 9 | var conf = scriptTypesConf[i]; 10 | scriptTypes.push({matches: conf.matches, mode: conf.mode && CodeMirror.getMode(config, conf.mode)}); 11 | } 12 | scriptTypes.push({matches: /./, 13 | mode: CodeMirror.getMode(config, "text/plain")}); 14 | 15 | function html(stream, state) { 16 | var tagName = state.htmlState.tagName; 17 | var style = htmlMode.token(stream, state.htmlState); 18 | if (tagName == "script" && /\btag\b/.test(style) && stream.current() == ">") { 19 | // Script block: mode to change to depends on type attribute 20 | var scriptType = stream.string.slice(Math.max(0, stream.pos - 100), stream.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i); 21 | scriptType = scriptType ? scriptType[1] : ""; 22 | if (scriptType && /[\"\']/.test(scriptType.charAt(0))) scriptType = scriptType.slice(1, scriptType.length - 1); 23 | for (var i = 0; i < scriptTypes.length; ++i) { 24 | var tp = scriptTypes[i]; 25 | if (typeof tp.matches == "string" ? scriptType == tp.matches : tp.matches.test(scriptType)) { 26 | if (tp.mode) { 27 | state.token = script; 28 | state.localMode = tp.mode; 29 | state.localState = tp.mode.startState && tp.mode.startState(htmlMode.indent(state.htmlState, "")); 30 | } 31 | break; 32 | } 33 | } 34 | } else if (tagName == "style" && /\btag\b/.test(style) && stream.current() == ">") { 35 | state.token = css; 36 | state.localMode = cssMode; 37 | state.localState = cssMode.startState(htmlMode.indent(state.htmlState, "")); 38 | } 39 | return style; 40 | } 41 | function maybeBackup(stream, pat, style) { 42 | var cur = stream.current(); 43 | var close = cur.search(pat), m; 44 | if (close > -1) stream.backUp(cur.length - close); 45 | else if (m = cur.match(/<\/?$/)) { 46 | stream.backUp(cur.length); 47 | if (!stream.match(pat, false)) stream.match(cur[0]); 48 | } 49 | return style; 50 | } 51 | function script(stream, state) { 52 | if (stream.match(/^<\/\s*script\s*>/i, false)) { 53 | state.token = html; 54 | state.localState = state.localMode = null; 55 | return html(stream, state); 56 | } 57 | return maybeBackup(stream, /<\/\s*script\s*>/, 58 | state.localMode.token(stream, state.localState)); 59 | } 60 | function css(stream, state) { 61 | if (stream.match(/^<\/\s*style\s*>/i, false)) { 62 | state.token = html; 63 | state.localState = state.localMode = null; 64 | return html(stream, state); 65 | } 66 | return maybeBackup(stream, /<\/\s*style\s*>/, 67 | cssMode.token(stream, state.localState)); 68 | } 69 | 70 | return { 71 | startState: function() { 72 | var state = htmlMode.startState(); 73 | return {token: html, localMode: null, localState: null, htmlState: state}; 74 | }, 75 | 76 | copyState: function(state) { 77 | if (state.localState) 78 | var local = CodeMirror.copyState(state.localMode, state.localState); 79 | return {token: state.token, localMode: state.localMode, localState: local, 80 | htmlState: CodeMirror.copyState(htmlMode, state.htmlState)}; 81 | }, 82 | 83 | token: function(stream, state) { 84 | return state.token(stream, state); 85 | }, 86 | 87 | indent: function(state, textAfter) { 88 | if (!state.localMode || /^\s*<\//.test(textAfter)) 89 | return htmlMode.indent(state.htmlState, textAfter); 90 | else if (state.localMode.indent) 91 | return state.localMode.indent(state.localState, textAfter); 92 | else 93 | return CodeMirror.Pass; 94 | }, 95 | 96 | electricChars: "/{}:", 97 | 98 | innerMode: function(state) { 99 | return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode}; 100 | } 101 | }; 102 | }, "xml", "javascript", "css"); 103 | 104 | CodeMirror.defineMIME("text/html", "htmlmixed"); 105 | -------------------------------------------------------------------------------- /rshtml/search3.html: -------------------------------------------------------------------------------- 1 | Search Files 2 | 3 | 100 | 101 | back to index
102 | 103 | Search Local 104 | Search Remote 105 | boolexp 106 | 107 | searchLimit 108 |

109 | 110 | 111 | -------------------------------------------------------------------------------- /rshtml/term_tree.js: -------------------------------------------------------------------------------- 1 | return; 2 | 3 | lightbulb = "http://t3.gstatic.com/images?q=tbn:ANd9GcRKQt_3ZpHSJmRNRnHl2cQU7WqI3Nzsv3hjVJHkYxLvwG_JEd-1bYLn-fUE1A"; 4 | function s4() { 5 | return Math.floor((1 + Math.random()) * 0x10000) 6 | .toString(16) 7 | .substring(1); 8 | }; 9 | function GUID() { 10 | return s4() + s4()+s4(); 11 | } 12 | window.conceptUpdate=function(event){ 13 | if(event.which==13){ 14 | var imageListB = $('.imageListHolder'); 15 | findImagesForTerms(event.target.value, function (result) { 16 | imageListB.html(result); 17 | }); 18 | } 19 | }; 20 | 21 | function basicBoxHTML(){ 22 | c=$('#box').clone(); 23 | c.find('div').remove('div').find('div').empty('div'); 24 | return c.html(); 25 | } 26 | function googImgClicked (img){ 27 | var ji = $(img); 28 | ji.addClass('selectedImg'); 29 | console.log('clicked img'); 30 | silh = ji.parent().parent().parent().parent().find('.selectedImageListHolder'); 31 | silh.append(ji.clone()); 32 | //console.dir(img); 33 | } 34 | function findImagesForTerms(terms, imagesFoundCalback) { 35 | $.getJSON("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&callback=?", { 36 | q: terms, 37 | start: 0 38 | }, function (images) { 39 | var imageList = $('
    '); 40 | for (image in images.responseData.results) { 41 | thisImage = images.responseData.results[image]; 42 | $(imageList).append("
  1. "); 43 | //console.dir(thisImage); 44 | } 45 | imagesFoundCalback(imageList); 46 | console.dir(images.responseData); 47 | }); 48 | } 49 | //findImagesForTerms('nucleus accumbens', function (result) { 50 | // console.log('got result:'); 51 | // console.log($(result).html()); 52 | //}); 53 | 54 | function getUnselectedText(containerEl) { 55 | var sel, range, tempRange, before = "", after = ""; 56 | if (typeof window.getSelection != "undefined") { 57 | sel = window.getSelection(); 58 | if (sel.rangeCount) { 59 | range = sel.getRangeAt(0); 60 | } else { 61 | range = document.createRange(); 62 | range.collapse(true); 63 | } 64 | tempRange = document.createRange(); 65 | tempRange.selectNodeContents(containerEl); 66 | tempRange.setEnd(range.startContainer, range.startOffset); 67 | before = tempRange.toString(); 68 | 69 | tempRange.selectNodeContents(containerEl); 70 | tempRange.setStart(range.endContainer, range.endOffset); 71 | after = tempRange.toString(); 72 | 73 | tempRange.detach(); 74 | } else if ( (sel = document.selection) && sel.type != "Control") { 75 | range = sel.createRange(); 76 | tempRange = document.body.createTextRange(); 77 | tempRange.moveToElementText(containerEl); 78 | tempRange.setEndPoint("EndToStart", range); 79 | before = tempRange.text; 80 | 81 | tempRange.moveToElementText(containerEl); 82 | tempRange.setEndPoint("StartToEnd", range); 83 | after = tempRange.text; 84 | } 85 | return { 86 | before: before.split(' ').slice(-5).join(' '), 87 | after: after.split(' ').slice(0,5).join(' ') 88 | }; 89 | } 90 | 91 | function surroundSelection() { 92 | var span = document.createElement("span"); 93 | jspan = $(span); 94 | jspan.addClass('selectedTerms'); 95 | var id='vizencoderHolderID'+GUID(); 96 | jspan.attr('id',id); 97 | if (window.getSelection) { 98 | console.log(getUnselectedText($('#box')[0])); 99 | var sel = window.getSelection(); 100 | if (sel.rangeCount) { 101 | var range = sel.getRangeAt(0).cloneRange(); 102 | stringy = range.toString(); 103 | range.surroundContents(span); 104 | sel.removeAllRanges(); 105 | //sel.addRange(range); 106 | //range.removeAllRanges(); 107 | jspan.append("
    "); 108 | var vh = $(span).find('.vizencoderHolder'); //TODO: use ID instead of just class 109 | vh.append("Concept"); 110 | vh.append("✍Visual ideas"); 111 | vh.append(""); 112 | vh.append(""); 113 | var imageList = vh.find('.imageListHolder'); 114 | findImagesForTerms(stringy, function (result) { 115 | imageList.html(result); 116 | }); 117 | 118 | } 119 | } 120 | } 121 | 122 | 123 | var text = document.getElementById('text') 124 | -------------------------------------------------------------------------------- /rshtml/preview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeMirror: HTML5 preview 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 27 | 28 | 29 |
    30 |

    HTML5 preview

    31 | 32 |

    Local notes - back to index 33 | 34 | 36 | 37 |

    38 | 102 | 103 | 156 |
    157 | -------------------------------------------------------------------------------- /rshtml/codemirror/mode/css/test.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var mode = CodeMirror.getMode({tabSize: 1}, "css"); 3 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } 4 | function IT(name) { test.indentation(name, mode, Array.prototype.slice.call(arguments, 1)); } 5 | 6 | // Requires at least one media query 7 | MT("atMediaEmpty", 8 | "[def @media] [error {] }"); 9 | 10 | MT("atMediaMultiple", 11 | "[def @media] [keyword not] [attribute screen] [operator and] ([property color]), [keyword not] [attribute print] [operator and] ([property color]) { }"); 12 | 13 | MT("atMediaCheckStack", 14 | "[def @media] [attribute screen] { } [tag foo] { }"); 15 | 16 | MT("atMediaCheckStack", 17 | "[def @media] [attribute screen] ([property color]) { } [tag foo] { }"); 18 | 19 | MT("atMediaPropertyOnly", 20 | "[def @media] ([property color]) { } [tag foo] { }"); 21 | 22 | MT("atMediaCheckStackInvalidAttribute", 23 | "[def @media] [attribute&error foobarhello] { [tag foo] { } }"); 24 | 25 | MT("atMediaCheckStackInvalidAttribute", 26 | "[def @media] [attribute&error foobarhello] { } [tag foo] { }"); 27 | 28 | // Error, because "and" is only allowed immediately preceding a media expression 29 | MT("atMediaInvalidAttribute", 30 | "[def @media] [attribute&error foobarhello] { }"); 31 | 32 | // Error, because "and" is only allowed immediately preceding a media expression 33 | MT("atMediaInvalidAnd", 34 | "[def @media] [error and] [attribute screen] { }"); 35 | 36 | // Error, because "not" is only allowed as the first item in each media query 37 | MT("atMediaInvalidNot", 38 | "[def @media] [attribute screen] [error not] ([error not]) { }"); 39 | 40 | // Error, because "only" is only allowed as the first item in each media query 41 | MT("atMediaInvalidOnly", 42 | "[def @media] [attribute screen] [error only] ([error only]) { }"); 43 | 44 | // Error, because "foobarhello" is neither a known type or property, but 45 | // property was expected (after "and"), and it should be in parenthese. 46 | MT("atMediaUnknownType", 47 | "[def @media] [attribute screen] [operator and] [error foobarhello] { }"); 48 | 49 | // Error, because "color" is not a known type, but is a known property, and 50 | // should be in parentheses. 51 | MT("atMediaInvalidType", 52 | "[def @media] [attribute screen] [operator and] [error color] { }"); 53 | 54 | // Error, because "print" is not a known property, but is a known type, 55 | // and should not be in parenthese. 56 | MT("atMediaInvalidProperty", 57 | "[def @media] [attribute screen] [operator and] ([error print]) { }"); 58 | 59 | // Soft error, because "foobarhello" is not a known property or type. 60 | MT("atMediaUnknownProperty", 61 | "[def @media] [attribute screen] [operator and] ([property&error foobarhello]) { }"); 62 | 63 | // Make sure nesting works with media queries 64 | MT("atMediaMaxWidthNested", 65 | "[def @media] [attribute screen] [operator and] ([property max-width][operator :] [number 25px]) { [tag foo] { } }"); 66 | 67 | MT("tagSelector", 68 | "[tag foo] { }"); 69 | 70 | MT("classSelector", 71 | "[qualifier .foo-bar_hello] { }"); 72 | 73 | MT("idSelector", 74 | "[builtin #foo] { [error #foo] }"); 75 | 76 | MT("tagSelectorUnclosed", 77 | "[tag foo] { [property margin][operator :] [number 0] } [tag bar] { }"); 78 | 79 | MT("tagStringNoQuotes", 80 | "[tag foo] { [property font-family][operator :] [variable-2 hello] [variable-2 world]; }"); 81 | 82 | MT("tagStringDouble", 83 | "[tag foo] { [property font-family][operator :] [string \"hello world\"]; }"); 84 | 85 | MT("tagStringSingle", 86 | "[tag foo] { [property font-family][operator :] [string 'hello world']; }"); 87 | 88 | MT("tagColorKeyword", 89 | "[tag foo] {" + 90 | "[property color][operator :] [keyword black];" + 91 | "[property color][operator :] [keyword navy];" + 92 | "[property color][operator :] [keyword yellow];" + 93 | "}"); 94 | 95 | MT("tagColorHex3", 96 | "[tag foo] { [property background][operator :] [atom #fff]; }"); 97 | 98 | MT("tagColorHex6", 99 | "[tag foo] { [property background][operator :] [atom #ffffff]; }"); 100 | 101 | MT("tagColorHex4", 102 | "[tag foo] { [property background][operator :] [atom&error #ffff]; }"); 103 | 104 | MT("tagColorHexInvalid", 105 | "[tag foo] { [property background][operator :] [atom&error #ffg]; }"); 106 | 107 | MT("tagNegativeNumber", 108 | "[tag foo] { [property margin][operator :] [number -5px]; }"); 109 | 110 | MT("tagPositiveNumber", 111 | "[tag foo] { [property padding][operator :] [number 5px]; }"); 112 | 113 | MT("tagVendor", 114 | "[tag foo] { [meta -foo-][property box-sizing][operator :] [meta -foo-][string-2 border-box]; }"); 115 | 116 | MT("tagBogusProperty", 117 | "[tag foo] { [property&error barhelloworld][operator :] [number 0]; }"); 118 | 119 | MT("tagTwoProperties", 120 | "[tag foo] { [property margin][operator :] [number 0]; [property padding][operator :] [number 0]; }"); 121 | 122 | MT("tagTwoPropertiesURL", 123 | "[tag foo] { [property background][operator :] [string-2 url]([string //example.com/foo.png]); [property padding][operator :] [number 0]; }"); 124 | 125 | MT("commentSGML", 126 | "[comment ]"); 127 | 128 | IT("tagSelector", 129 | "strong, em [1 { background][2 : rgba][3 (255, 255, 0, .2][2 )][1 ;]}"); 130 | })(); 131 | -------------------------------------------------------------------------------- /rshtml/tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Word Tree 5 | 6 | 7 | 8 | 9 | 30 | 31 | 32 |
    33 | 37 |
    38 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /rshtml/search.html: -------------------------------------------------------------------------------- 1 | Search Files 2 | 3 | 4 | 9 | 10 | 11 | 12 | back to index
    13 |
    14 | 15 | Search Local 16 | Search Remote 17 | Search Distant/Turtle 18 | boolexp 19 | 20 | searchLimit 21 |

    22 |
    23 | 24 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /services/rsWebViewItems.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * RetroShare is distributed under the following license: 3 | * 4 | * Copyright (C) 2015 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | ****************************************************************/ 21 | 22 | #include 23 | #include "serialiser/rsbaseserial.h" 24 | #include "serialiser/rstlvbase.h" 25 | 26 | #include "services/rsWebViewItems.h" 27 | 28 | /*** 29 | #define RSSERIAL_DEBUG 1 30 | ***/ 31 | 32 | #include 33 | 34 | #define HOLLERITH_LEN_SPEC 4 35 | /*************************************************************************/ 36 | 37 | std::ostream& RsWebViewDataItem::print(std::ostream &out, uint16_t indent) 38 | { 39 | printRsItemBase(out, "RsWebViewDataItem", indent); 40 | uint16_t int_Indent = indent + 2; 41 | printIndent(out, int_Indent); 42 | out << "flags: " << flags << std::endl; 43 | 44 | printIndent(out, int_Indent); 45 | out << "data size: " << std::hex << data_size << std::dec << std::endl; 46 | 47 | printRsItemEnd(out, "RsWebViewDataItem", indent); 48 | return out; 49 | } 50 | 51 | /*************************************************************************/ 52 | uint32_t RsWebViewDataItem::serial_size() const 53 | { 54 | uint32_t s = 8; /* header */ 55 | s += 4; /* flags */ 56 | s += 4; /* data_size */ 57 | //s += m_msg.length()+HOLLERITH_LEN_SPEC; /* data */ 58 | s += getRawStringSize(m_msg); 59 | 60 | return s; 61 | } 62 | 63 | /* serialise the data to the buffer */ 64 | bool RsWebViewDataItem::serialise(void *data, uint32_t& pktsize) 65 | { 66 | uint32_t tlvsize = serial_size() ; 67 | uint32_t offset = 0; 68 | 69 | if (pktsize < tlvsize) 70 | return false; /* not enough space */ 71 | 72 | pktsize = tlvsize; 73 | 74 | bool ok = true; 75 | 76 | ok &= setRsItemHeader(data, tlvsize, PacketId(), tlvsize); 77 | 78 | #ifdef RSSERIAL_DEBUG 79 | std::cerr << "RsWebViewSerialiser::serialiseWebViewDataItem() Header: " << ok << std::endl; 80 | std::cerr << "RsWebViewSerialiser::serialiseWebViewDataItem() Size: " << tlvsize << std::endl; 81 | #endif 82 | 83 | /* skip the header */ 84 | offset += 8; 85 | 86 | /* add mandatory parts first */ 87 | ok &= setRawUInt32(data, tlvsize, &offset, flags); 88 | ok &= setRawUInt32(data, tlvsize, &offset, data_size); 89 | 90 | 91 | ok &= setRawString(data, tlvsize, &offset, m_msg ); 92 | std::cout << "string sizes: " << getRawStringSize(m_msg) << " OR " << m_msg.size() << "\n"; 93 | 94 | if (offset != tlvsize) 95 | { 96 | ok = false; 97 | std::cerr << "RsWebViewSerialiser::serialiseWebViewPingItem() Size Error! " << std::endl; 98 | std::cerr << "expected " << tlvsize << " got " << offset << std::endl; 99 | std::cerr << "m_msg looks like " << m_msg << std::endl; 100 | } 101 | 102 | return ok; 103 | } 104 | /* serialise the data to the buffer */ 105 | 106 | /*************************************************************************/ 107 | /*************************************************************************/ 108 | 109 | RsWebViewDataItem::RsWebViewDataItem(void *data, uint32_t pktsize) 110 | : RsWebViewItem(RS_PKT_SUBTYPE_WebView_DATA) 111 | { 112 | /* get the type and size */ 113 | uint32_t rstype = getRsItemId(data); 114 | uint32_t rssize = getRsItemSize(data); 115 | 116 | uint32_t offset = 0; 117 | 118 | if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || (RS_SERVICE_TYPE_WebView_PLUGIN != getRsItemService(rstype)) || (RS_PKT_SUBTYPE_WebView_DATA != getRsItemSubType(rstype))) 119 | throw std::runtime_error("Wrong packet subtype") ; 120 | 121 | if (pktsize < rssize) /* check size */ 122 | throw std::runtime_error("Not enough space") ; 123 | 124 | bool ok = true; 125 | 126 | /* skip the header */ 127 | offset += 8; 128 | 129 | /* get mandatory parts first */ 130 | ok &= getRawUInt32(data, rssize, &offset, &flags); 131 | ok &= getRawUInt32(data, rssize, &offset, &data_size); 132 | 133 | 134 | ok &= getRawString(data, rssize, &offset, m_msg ); 135 | 136 | if (offset != rssize) 137 | throw std::runtime_error("Serialization error.") ; 138 | 139 | if (!ok) 140 | throw std::runtime_error("Serialization error.") ; 141 | } 142 | /*************************************************************************/ 143 | 144 | RsItem* RsWebViewSerialiser::deserialise(void *data, uint32_t *pktsize) 145 | { 146 | #ifdef RSSERIAL_DEBUG 147 | std::cerr << "RsWebViewSerialiser::deserialise()" << std::endl; 148 | #endif 149 | 150 | /* get the type and size */ 151 | uint32_t rstype = getRsItemId(data); 152 | 153 | if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || (RS_SERVICE_TYPE_WebView_PLUGIN != getRsItemService(rstype))) 154 | return NULL ; 155 | 156 | try 157 | { 158 | switch(getRsItemSubType(rstype)) 159 | { 160 | case RS_PKT_SUBTYPE_WebView_DATA: return new RsWebViewDataItem(data, *pktsize); 161 | 162 | default: 163 | return NULL; 164 | } 165 | } 166 | catch(std::exception& e) 167 | { 168 | std::cerr << "RsWebViewSerialiser: deserialization error: " << e.what() << std::endl; 169 | return NULL; 170 | } 171 | } 172 | 173 | 174 | /*************************************************************************/ 175 | 176 | -------------------------------------------------------------------------------- /rshtml/index.html: -------------------------------------------------------------------------------- 1 | Index 2 | 3 | 4 | 5 | 6 |

    WebScriptRS

    7 |
    8 |
    9 |

    Fun things ;)

    10 | 11 | Broadcast Chat Talk to all friends using WSRS
    12 | Ivank simple drivable car simple car demo with basic networking added -requires webgl
    13 | 14 |
    15 |
    16 |

    Notes or js/HTML fiddles

    17 | ACE Editor+editable text+localstorage test out html and js snippets
    18 | Codemirror + iframe + localstorage Codemirror html live edit demo with access to RS and stored localy
    19 |
    20 |
    21 |

    Scripted versions of existing RetroShare components

    22 | Search Files Search your network for files
    23 | 25 |
    26 |
    27 |

    Old tests

    28 | List friends and some basic info
    29 |
    download URL demos downloading http:/ links to downloads folder
    30 | MicroBlog Sends data to peers when seen. Sync method seriously stinks
    31 |
    32 | WebGL:
    33 | Broadcast Particles - broadcast painting lots of circles with three.js
    34 | p2p Averaging Physics Test - all clients control all objects
    35 | p2p owned-objects Physics Test - clients control their own objects
    36 | 3d chat tree test basic message+parent data is sent over the network, local 3d display
    37 |
    38 | 47 |
    48 |

    Extra Info

    49 | Source can be found at github for now 50 |
    51 |
    52 | 53 |
    54 |
    55 |

    Live Data:

    56 |
    57 | Compatable Peers: 58 |
    59 | Last packet from peers 60 |
    61 |
    62 |
    63 | 64 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /rshtml/speech.js: -------------------------------------------------------------------------------- 1 | window.Speech = (function (undefined) { 2 | 3 | // https://github.com/aralejs/events ====================================== 4 | 5 | var eventSplitter = /\s+/, 6 | Events = function () {} 7 | 8 | Events.prototype.on = function (events, callback, context) { 9 | var cache, event, list 10 | if (!callback) return this 11 | 12 | cache = this.__events || (this.__events = {}) 13 | events = events.split(eventSplitter) 14 | 15 | while (event = events.shift()) { 16 | list = cache[event] || (cache[event] = []) 17 | list.push(callback, context) 18 | } 19 | 20 | return this 21 | } 22 | 23 | Events.prototype.off = function (events, callback, context) { 24 | var cache, event, list, i 25 | 26 | if (!(cache = this.__events)) return this 27 | if (!(events || callback || context)) { 28 | delete this.__events 29 | return this 30 | } 31 | 32 | events = events ? events.split(eventSplitter) : Object.keys(cache) 33 | 34 | while (event = events.shift()) { 35 | list = cache[event] 36 | if (!list) continue 37 | 38 | if (!(callback || context)) { 39 | delete cache[event] 40 | continue 41 | } 42 | 43 | for (i = list.length - 2; i >= 0; i -= 2) { 44 | if (!(callback && list[i] !== callback || 45 | context && list[i + 1] !== context)) { 46 | list.splice(i, 2) 47 | } 48 | } 49 | } 50 | 51 | return this 52 | } 53 | 54 | Events.prototype.emit = function(events) { 55 | var cache, event, all, list, i, len, rest = [], args 56 | if (!(cache = this.__events)) return this 57 | 58 | events = events.split(eventSplitter) 59 | 60 | for (i = 1, len = arguments.length; i < len; i++) { 61 | rest[i - 1] = arguments[i] 62 | } 63 | 64 | while (event = events.shift()) { 65 | if (all = cache.all) all = all.slice() 66 | if (list = cache[event]) list = list.slice() 67 | 68 | if (list) { 69 | for (i = 0, len = list.length; i < len; i += 2) { 70 | list[i].apply(list[i + 1] || this, rest) 71 | } 72 | } 73 | 74 | if (all) { 75 | args = [event].concat(rest) 76 | for (i = 0, len = all.length; i < len; i += 2) { 77 | all[i].apply(all[i + 1] || this, args) 78 | } 79 | } 80 | } 81 | 82 | return this 83 | } 84 | 85 | Events.mixTo = function(receiver) { 86 | receiver = receiver.prototype || receiver 87 | var proto = Events.prototype 88 | 89 | for (var p in proto) { 90 | if (proto.hasOwnProperty(p)) { 91 | receiver[p] = proto[p] 92 | } 93 | } 94 | } 95 | 96 | // Speech instance ======================================================== 97 | 98 | function Speech (options) { 99 | 100 | // default options 101 | this.options = { 102 | debugging: false, 103 | continuous: false, 104 | interimResults: false, 105 | autoRestart: false 106 | } 107 | 108 | // merge user options 109 | if (Object.prototype.toString.call(options) === '[object Object]') { 110 | for (var op in options) { 111 | this.options[op] = options[op] 112 | } 113 | } 114 | 115 | this.active = false 116 | this.manualStopped = false 117 | this.history = [] 118 | this.lastIndex = -1 119 | this.lastResult = '' 120 | this.recognition = new webkitSpeechRecognition() 121 | 122 | var rec = this.recognition, 123 | self = this 124 | 125 | rec.continuous = self.options.continuous 126 | rec.interimResults = self.options.interimResults 127 | if (options.lang) rec.lang = options.lang 128 | 129 | rec.onstart = function () { 130 | self.active = true 131 | this.manualStopped = false 132 | self.emit('start') 133 | } 134 | 135 | rec.onresult = function (e) { 136 | if (!e.results || !e.results.length) return 137 | 138 | var updatedResult = e.results[e.resultIndex], 139 | transcript = updatedResult[0].transcript.replace(/^\s*/, '') 140 | 141 | // new sentence? 142 | if (e.resultIndex !== self.lastIndex) { 143 | self.lastIndex = e.resultIndex 144 | self.lastResult = '' 145 | } 146 | 147 | // avoid some redundancy 148 | if (transcript === self.lastResult && !updatedResult.isFinal) return 149 | if (transcript.length < self.lastResult.length) return 150 | 151 | self.lastResult = transcript 152 | 153 | if (updatedResult.isFinal) { 154 | // final sentence! we can do work! 155 | self.history.push(transcript) 156 | self.emit('finalResult', transcript) 157 | } else { 158 | // interim, let's update stuff on screen 159 | self.emit('interimResult', transcript) 160 | } 161 | 162 | if (self.options.debugging) { 163 | console.log(transcript + (updatedResult.isFinal ? ' (final)' : '')) 164 | } 165 | } 166 | 167 | rec.onerror = function (e) { 168 | self.emit('error', e) 169 | } 170 | 171 | rec.onend = function () { 172 | self.active = false 173 | self.history = [] 174 | self.lastIndex = -1 175 | self.lastResult = '' 176 | self.emit('end') 177 | if (self.options.autoRestart && !self.manualStopped) { 178 | self.start() 179 | } 180 | } 181 | 182 | } 183 | 184 | Speech.prototype.start = function () { 185 | if (this.active) return 186 | this.recognition.start() 187 | } 188 | 189 | Speech.prototype.stop = function () { 190 | if (!this.active) return 191 | this.manualStopped = true 192 | this.recognition.stop() 193 | } 194 | 195 | Events.mixTo(Speech) 196 | 197 | return Speech 198 | 199 | })() 200 | -------------------------------------------------------------------------------- /WebViewPlugin.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * RetroShare is distributed under the following license: 3 | * 4 | * Copyright (C) 2015 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | ****************************************************************/ 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "WebViewPlugin.h" 31 | #include "interface/rsWebView.h" 32 | #include "gui/WebViewMainpage.h" 33 | #include "gui/WebViewNotify.h" 34 | 35 | 36 | #define IMAGE_WebView ":/images/talking_on.svg" 37 | 38 | static void *inited = new WebViewPlugin() ; 39 | 40 | extern "C" { 41 | 42 | // This is *the* functions required by RS plugin system to give RS access to the plugin. 43 | // Be careful to: 44 | // - always respect the C linkage convention 45 | // - always return an object of type RsPlugin* 46 | // 47 | void *RETROSHARE_PLUGIN_provide() 48 | { 49 | static WebViewPlugin *p = new WebViewPlugin() ; 50 | 51 | return (void*)p ; 52 | } 53 | 54 | // This symbol contains the svn revision number grabbed from the executable. 55 | // It will be tested by RS to load the plugin automatically, since it is safe to load plugins 56 | // with same revision numbers, assuming that the revision numbers are up-to-date. 57 | // 58 | uint32_t RETROSHARE_PLUGIN_revision = RS_REVISION_NUMBER ; 59 | 60 | // This symbol contains the svn revision number grabbed from the executable. 61 | // It will be tested by RS to load the plugin automatically, since it is safe to load plugins 62 | // with same revision numbers, assuming that the revision numbers are up-to-date. 63 | // 64 | uint32_t RETROSHARE_PLUGIN_api = RS_PLUGIN_API_VERSION ; 65 | } 66 | 67 | void WebViewPlugin::getPluginVersion(int& major, int& minor, int& build, int& svn_rev) const 68 | { 69 | major = RS_MAJOR_VERSION ; 70 | minor = RS_MINOR_VERSION ; 71 | build = RS_BUILD_NUMBER ; 72 | svn_rev = RS_REVISION_NUMBER ; 73 | } 74 | 75 | WebViewPlugin::WebViewPlugin() 76 | { 77 | qRegisterMetaType("RsPeerId"); 78 | mainpage = NULL ; 79 | mWebView = NULL ; 80 | mPlugInHandler = NULL; 81 | mPeers = NULL; 82 | config_page = NULL ; 83 | mIcon = NULL ; 84 | 85 | mWebViewNotify = new WebViewNotify; 86 | } 87 | 88 | void WebViewPlugin::setInterfaces(RsPlugInInterfaces &interfaces) 89 | { 90 | mPeers = interfaces.mPeers; 91 | } 92 | 93 | /*ConfigPage *WebViewPlugin::qt_config_page() const 94 | { 95 | // The config pages are deleted when config is closed, so it's important not to static the 96 | // created object. 97 | // 98 | return new AudioInputConfig() ; 99 | }*/ 100 | 101 | QDialog *WebViewPlugin::qt_about_page() const 102 | { 103 | static QMessageBox *about_dialog = NULL ; 104 | 105 | if(about_dialog == NULL) 106 | { 107 | about_dialog = new QMessageBox() ; 108 | 109 | QString text ; 110 | text += QObject::tr("

    RetroShare WebView plugin


    * Contributors: Cyril Soler, Josselin Jacquard
    ") ; 111 | text += QObject::tr("
    The WebView plugin adds WebView to the private chat window of RetroShare. to use it, proceed as follows:
      ") ; 112 | text += QObject::tr("
    • setup microphone levels using the configuration panel
    • ") ; 113 | text += QObject::tr("
    • check your microphone by looking at the VU-metters
    • ") ; 114 | text += QObject::tr("
    • in the private chat, enable sound input/output by clicking on the two WebView icons
    ") ; 115 | text += QObject::tr("Your friend needs to run the plugin to talk/listen to you, or course.") ; 116 | text += QObject::tr("

    This is an experimental feature. Don't hesitate to send comments and suggestion to the RS dev team.") ; 117 | 118 | about_dialog->setText(text) ; 119 | about_dialog->setStandardButtons(QMessageBox::Ok) ; 120 | } 121 | 122 | return about_dialog ; 123 | } 124 | 125 | /*ChatWidgetHolder *WebViewPlugin::qt_get_chat_widget_holder(ChatWidget *chatWidget) const 126 | { 127 | switch (chatWidget->chatType()) { 128 | case ChatWidget::CHATTYPE_PRIVATE: 129 | return new WebViewChatWidgetHolder(chatWidget, mWebViewNotify); 130 | case ChatWidget::CHATTYPE_UNKNOWN: 131 | case ChatWidget::CHATTYPE_LOBBY: 132 | case ChatWidget::CHATTYPE_DISTANT: 133 | break; 134 | } 135 | 136 | return NULL; 137 | }*/ 138 | 139 | p3Service *WebViewPlugin::p3_service() const 140 | { 141 | if(mWebView == NULL) 142 | rsWebView = mWebView = new p3WebView(mPlugInHandler,mWebViewNotify) ; // , 3600 * 24 * 30 * 6); // 6 Months 143 | 144 | return mWebView ; 145 | } 146 | 147 | void WebViewPlugin::setPlugInHandler(RsPluginHandler *pgHandler) 148 | { 149 | mPlugInHandler = pgHandler; 150 | } 151 | 152 | QIcon *WebViewPlugin::qt_icon() const 153 | { 154 | if (mIcon == NULL) { 155 | Q_INIT_RESOURCE(WebView_images); 156 | 157 | mIcon = new QIcon(IMAGE_WebView); 158 | } 159 | 160 | return mIcon; 161 | } 162 | MainPage *WebViewPlugin::qt_page() const 163 | { 164 | if(mainpage == NULL){ 165 | mainpage = new WebViewMainpage(0, mWebViewNotify);//mPeers, mFiles) ; 166 | //tpage = new WebViewMainpage( ); 167 | //mainpage = tpage; 168 | } 169 | 170 | return mainpage ; 171 | } 172 | 173 | std::string WebViewPlugin::getShortPluginDescription() const 174 | { 175 | return "WebView"; 176 | } 177 | 178 | std::string WebViewPlugin::getPluginName() const 179 | { 180 | return "WebViewPlugin"; 181 | } 182 | 183 | QTranslator* WebViewPlugin::qt_translator(QApplication */*app*/, const QString& languageCode, const QString& externalDir) const 184 | { 185 | return NULL; 186 | } 187 | 188 | void WebViewPlugin::qt_sound_events(SoundEvents &/*events*/) const 189 | { 190 | // events.addEvent(QApplication::translate("WebView", "WebView"), QApplication::translate("WebView", "Incoming call"), WebView_SOUND_INCOMING_CALL); 191 | } 192 | 193 | /*ToasterNotify *WebViewPlugin::qt_toasterNotify(){ 194 | if (!mWebViewToasterNotify) { 195 | mWebViewToasterNotify = new WebViewToasterNotify(mWebView, mWebViewNotify); 196 | } 197 | return mWebViewToasterNotify; 198 | }*/ 199 | -------------------------------------------------------------------------------- /rshtml/interactiveparticles.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | three.js canvas - interactive particles 6 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 213 | 214 | 215 | 216 | -------------------------------------------------------------------------------- /rshtml/codemirror/codemirror.css: -------------------------------------------------------------------------------- 1 | /* BASICS */ 2 | 3 | .CodeMirror { 4 | /* Set height, width, borders, and global font properties here */ 5 | font-family: monospace; 6 | height: 300px; 7 | } 8 | .CodeMirror-scroll { 9 | /* Set scrolling behaviour here */ 10 | overflow: auto; 11 | } 12 | 13 | /* PADDING */ 14 | 15 | .CodeMirror-lines { 16 | padding: 4px 0; /* Vertical padding around content */ 17 | } 18 | .CodeMirror pre { 19 | padding: 0 4px; /* Horizontal padding of content */ 20 | } 21 | 22 | .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { 23 | background-color: white; /* The little square between H and V scrollbars */ 24 | } 25 | 26 | /* GUTTER */ 27 | 28 | .CodeMirror-gutters { 29 | border-right: 1px solid #ddd; 30 | background-color: #f7f7f7; 31 | white-space: nowrap; 32 | } 33 | .CodeMirror-linenumbers {} 34 | .CodeMirror-linenumber { 35 | padding: 0 3px 0 5px; 36 | min-width: 20px; 37 | text-align: right; 38 | color: #999; 39 | } 40 | 41 | /* CURSOR */ 42 | 43 | .CodeMirror div.CodeMirror-cursor { 44 | border-left: 1px solid black; 45 | z-index: 3; 46 | } 47 | /* Shown when moving in bi-directional text */ 48 | .CodeMirror div.CodeMirror-secondarycursor { 49 | border-left: 1px solid silver; 50 | } 51 | .CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { 52 | width: auto; 53 | border: 0; 54 | background: #7e7; 55 | z-index: 1; 56 | } 57 | /* Can style cursor different in overwrite (non-insert) mode */ 58 | .CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {} 59 | 60 | .cm-tab { display: inline-block; } 61 | 62 | /* DEFAULT THEME */ 63 | 64 | .cm-s-default .cm-keyword {color: #708;} 65 | .cm-s-default .cm-atom {color: #219;} 66 | .cm-s-default .cm-number {color: #164;} 67 | .cm-s-default .cm-def {color: #00f;} 68 | .cm-s-default .cm-variable {color: black;} 69 | .cm-s-default .cm-variable-2 {color: #05a;} 70 | .cm-s-default .cm-variable-3 {color: #085;} 71 | .cm-s-default .cm-property {color: black;} 72 | .cm-s-default .cm-operator {color: black;} 73 | .cm-s-default .cm-comment {color: #a50;} 74 | .cm-s-default .cm-string {color: #a11;} 75 | .cm-s-default .cm-string-2 {color: #f50;} 76 | .cm-s-default .cm-meta {color: #555;} 77 | .cm-s-default .cm-qualifier {color: #555;} 78 | .cm-s-default .cm-builtin {color: #30a;} 79 | .cm-s-default .cm-bracket {color: #997;} 80 | .cm-s-default .cm-tag {color: #170;} 81 | .cm-s-default .cm-attribute {color: #00c;} 82 | .cm-s-default .cm-header {color: blue;} 83 | .cm-s-default .cm-quote {color: #090;} 84 | .cm-s-default .cm-hr {color: #999;} 85 | .cm-s-default .cm-link {color: #00c;} 86 | 87 | .cm-negative {color: #d44;} 88 | .cm-positive {color: #292;} 89 | .cm-header, .cm-strong {font-weight: bold;} 90 | .cm-em {font-style: italic;} 91 | .cm-link {text-decoration: underline;} 92 | 93 | .cm-s-default .cm-error {color: #f00;} 94 | .cm-invalidchar {color: #f00;} 95 | 96 | div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} 97 | div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} 98 | .CodeMirror-activeline-background {background: #e8f2ff;} 99 | 100 | /* STOP */ 101 | 102 | /* The rest of this file contains styles related to the mechanics of 103 | the editor. You probably shouldn't touch them. */ 104 | 105 | .CodeMirror { 106 | line-height: 1; 107 | position: relative; 108 | overflow: hidden; 109 | background: white; 110 | color: black; 111 | } 112 | 113 | .CodeMirror-scroll { 114 | /* 30px is the magic margin used to hide the element's real scrollbars */ 115 | /* See overflow: hidden in .CodeMirror */ 116 | margin-bottom: -30px; margin-right: -30px; 117 | padding-bottom: 30px; padding-right: 30px; 118 | height: 100%; 119 | outline: none; /* Prevent dragging from highlighting the element */ 120 | position: relative; 121 | -moz-box-sizing: content-box; 122 | box-sizing: content-box; 123 | } 124 | .CodeMirror-sizer { 125 | position: relative; 126 | } 127 | 128 | /* The fake, visible scrollbars. Used to force redraw during scrolling 129 | before actuall scrolling happens, thus preventing shaking and 130 | flickering artifacts. */ 131 | .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { 132 | position: absolute; 133 | z-index: 6; 134 | display: none; 135 | } 136 | .CodeMirror-vscrollbar { 137 | right: 0; top: 0; 138 | overflow-x: hidden; 139 | overflow-y: scroll; 140 | } 141 | .CodeMirror-hscrollbar { 142 | bottom: 0; left: 0; 143 | overflow-y: hidden; 144 | overflow-x: scroll; 145 | } 146 | .CodeMirror-scrollbar-filler { 147 | right: 0; bottom: 0; 148 | } 149 | .CodeMirror-gutter-filler { 150 | left: 0; bottom: 0; 151 | } 152 | 153 | .CodeMirror-gutters { 154 | position: absolute; left: 0; top: 0; 155 | padding-bottom: 30px; 156 | z-index: 3; 157 | } 158 | .CodeMirror-gutter { 159 | white-space: normal; 160 | height: 100%; 161 | -moz-box-sizing: content-box; 162 | box-sizing: content-box; 163 | padding-bottom: 30px; 164 | margin-bottom: -32px; 165 | display: inline-block; 166 | /* Hack to make IE7 behave */ 167 | *zoom:1; 168 | *display:inline; 169 | } 170 | .CodeMirror-gutter-elt { 171 | position: absolute; 172 | cursor: default; 173 | z-index: 4; 174 | } 175 | 176 | .CodeMirror-lines { 177 | cursor: text; 178 | } 179 | .CodeMirror pre { 180 | /* Reset some styles that the rest of the page might have set */ 181 | -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; 182 | border-width: 0; 183 | background: transparent; 184 | font-family: inherit; 185 | font-size: inherit; 186 | margin: 0; 187 | white-space: pre; 188 | word-wrap: normal; 189 | line-height: inherit; 190 | color: inherit; 191 | z-index: 2; 192 | position: relative; 193 | overflow: visible; 194 | } 195 | .CodeMirror-wrap pre { 196 | word-wrap: break-word; 197 | white-space: pre-wrap; 198 | word-break: normal; 199 | } 200 | .CodeMirror-code pre { 201 | border-right: 30px solid transparent; 202 | width: -webkit-fit-content; 203 | width: -moz-fit-content; 204 | width: fit-content; 205 | } 206 | .CodeMirror-wrap .CodeMirror-code pre { 207 | border-right: none; 208 | width: auto; 209 | } 210 | .CodeMirror-linebackground { 211 | position: absolute; 212 | left: 0; right: 0; top: 0; bottom: 0; 213 | z-index: 0; 214 | } 215 | 216 | .CodeMirror-linewidget { 217 | position: relative; 218 | z-index: 2; 219 | overflow: auto; 220 | } 221 | 222 | .CodeMirror-widget {} 223 | 224 | .CodeMirror-wrap .CodeMirror-scroll { 225 | overflow-x: hidden; 226 | } 227 | 228 | .CodeMirror-measure { 229 | position: absolute; 230 | width: 100%; 231 | height: 0; 232 | overflow: hidden; 233 | visibility: hidden; 234 | } 235 | .CodeMirror-measure pre { position: static; } 236 | 237 | .CodeMirror div.CodeMirror-cursor { 238 | position: absolute; 239 | visibility: hidden; 240 | border-right: none; 241 | width: 0; 242 | } 243 | .CodeMirror-focused div.CodeMirror-cursor { 244 | visibility: visible; 245 | } 246 | 247 | .CodeMirror-selected { background: #d9d9d9; } 248 | .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } 249 | 250 | .cm-searching { 251 | background: #ffa; 252 | background: rgba(255, 255, 0, .4); 253 | } 254 | 255 | /* IE7 hack to prevent it from returning funny offsetTops on the spans */ 256 | .CodeMirror span { *vertical-align: text-bottom; } 257 | 258 | @media print { 259 | /* Hide the cursor when printing */ 260 | .CodeMirror div.CodeMirror-cursor { 261 | visibility: hidden; 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /rshtml/libsha512.js: -------------------------------------------------------------------------------- 1 | (function() {/* 2 | A JavaScript implementation of the SHA family of hashes, as defined in FIPS 3 | PUB 180-2 as well as the corresponding HMAC implementation as defined in 4 | FIPS PUB 198a 5 | 6 | Copyright Brian Turek 2008-2012 7 | Distributed under the BSD License 8 | See http://caligatio.github.com/jsSHA/ for more information 9 | 10 | Several functions taken from Paul Johnson 11 | */ 12 | function n(a){throw a;}var q=null;function s(a,b){this.a=a;this.b=b}function u(a,b){var d=[],h=(1<>>5]|=(a.charCodeAt(g/b)&h)<<32-b-g%32;return{value:d,binLen:f}}function x(a){var b=[],d=a.length,h,f;0!==d%2&&n("String of HEX type must be in byte increments");for(h=0;h>>3]|=f<<24-4*(h%8);return{value:b,binLen:4*d}} 13 | function B(a){var b=[],d=0,h,f,g,k,m;-1===a.search(/^[a-zA-Z0-9=+\/]+$/)&&n("Invalid character in base-64 string");h=a.indexOf("=");a=a.replace(/\=/g,"");-1!==h&&h'); 140 | for (image in images.responseData.results) { 141 | thisImage = images.responseData.results[image]; 142 | $(imageList).append("
  2. "); 143 | //console.dir(thisImage); 144 | } 145 | imagesFoundCalback(imageList); 146 | console.dir(images.responseData);*/ 147 | }); 148 | } 149 | findImagesForTerms("cats",gotImgs); 150 | function gotImgs(images){ 151 | //externalImage1.src = images;//"https://dl.dropboxusercontent.com/u/139992952/stackoverflow/colorhouse.png"; 152 | } 153 | externalImage1.src="http://imgur.com/gallery/EMJjfjM" 154 | /////// draw text on canvas ///////// 155 | 156 | // create a canvas element 157 | /*var canvas1 = document.createElement('canvas'); 158 | var context1 = canvas1.getContext('2d'); 159 | context1.font = "Bold 40px Arial"; 160 | context1.fillStyle = "rgba(255,0,0,0.95)"; 161 | context1.fillText('Hello, world!', 0, 50); 162 | 163 | // canvas contents will be used for a texture 164 | var texture1 = new THREE.Texture(canvas1) 165 | texture1.needsUpdate = true; 166 | 167 | var material1 = new THREE.MeshBasicMaterial( {map: texture1, side:THREE.DoubleSide } ); 168 | material1.transparent = true; 169 | 170 | var mesh1 = new THREE.Mesh( 171 | new THREE.PlaneGeometry(canvas1.width, canvas1.height), 172 | material1 173 | ); 174 | mesh1.position.set(0,50,0); 175 | scene.add( mesh1 );*/ 176 | 177 | /////// draw image on canvas ///////// 178 | 179 | // create a canvas element 180 | var canvas2 = document.createElement('canvas'); 181 | var context2 = canvas2.getContext('2d'); 182 | // canvas contents will be used for a texture 183 | var texture2 = new THREE.Texture(canvas2); 184 | 185 | // load an image 186 | var imageObj = new Image(); 187 | imageObj.src = "images/Dice-Blue-1.png"; 188 | // after the image is loaded, this function executes 189 | imageObj.onload = function() 190 | { 191 | context2.drawImage(imageObj, 0, 0); 192 | if ( texture2 ) // checks if texture exists 193 | texture2.needsUpdate = true; 194 | }; 195 | 196 | var material2 = new THREE.MeshBasicMaterial( {map: texture2, side:THREE.DoubleSide} ); 197 | material2.transparent = true; 198 | 199 | var mesh2 = new THREE.Mesh( 200 | new THREE.PlaneGeometry(canvas2.width, canvas2.height), 201 | material2 202 | ); 203 | mesh2.position.set(0,50,-50); 204 | scene.add( mesh2 ); 205 | } 206 | 207 | function animate() 208 | { 209 | requestAnimationFrame( animate ); 210 | render(); 211 | update(); 212 | } 213 | 214 | function update() 215 | { 216 | if ( keyboard.pressed("z") ) 217 | { 218 | // do something 219 | } 220 | 221 | controls.update(); 222 | stats.update(); 223 | } 224 | 225 | function render() 226 | { 227 | renderer.render( scene, camera ); 228 | } 229 | 230 | 231 | 232 | 233 | 234 | -------------------------------------------------------------------------------- /services/p3WebView.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * RetroShare is distributed under the following license: 3 | * 4 | * Copyright (C) 2015 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | ****************************************************************/ 21 | 22 | #include "util/rsdir.h" 23 | #include "retroshare/rsiface.h" 24 | #include "pqi/pqibin.h" 25 | #include "pqi/pqistore.h" 26 | #include "pqi/p3linkmgr.h" 27 | #include 28 | #include 29 | 30 | #include // for std::istringstream 31 | 32 | #include "services/p3WebView.h" 33 | #include "services/rsWebViewItems.h" 34 | 35 | #include 36 | 37 | #include "gui/WebViewNotify.h" 38 | 39 | #include "../gui/webbridgers.h" 40 | 41 | 42 | //#define DEBUG_WebView 1 43 | 44 | 45 | /* DEFINE INTERFACE POINTER! */ 46 | RsWebView *rsWebView = NULL; 47 | 48 | 49 | 50 | #ifdef WINDOWS_SYS 51 | #include 52 | #include 53 | #endif 54 | 55 | static double getCurrentTS() 56 | { 57 | 58 | #ifndef WINDOWS_SYS 59 | struct timeval cts_tmp; 60 | gettimeofday(&cts_tmp, NULL); 61 | double cts = (cts_tmp.tv_sec) + ((double) cts_tmp.tv_usec) / 1000000.0; 62 | #else 63 | struct _timeb timebuf; 64 | _ftime( &timebuf); 65 | double cts = (timebuf.time) + ((double) timebuf.millitm) / 1000.0; 66 | #endif 67 | return cts; 68 | } 69 | 70 | static uint64_t convertTsTo64bits(double ts) 71 | { 72 | uint32_t secs = (uint32_t) ts; 73 | uint32_t usecs = (uint32_t) ((ts - (double) secs) * 1000000); 74 | uint64_t bits = (((uint64_t) secs) << 32) + usecs; 75 | return bits; 76 | } 77 | 78 | static double convert64bitsToTs(uint64_t bits) 79 | { 80 | uint32_t usecs = (uint32_t) (bits & 0xffffffff); 81 | uint32_t secs = (uint32_t) ((bits >> 32) & 0xffffffff); 82 | double ts = (secs) + ((double) usecs) / 1000000.0; 83 | 84 | return ts; 85 | } 86 | 87 | p3WebView::p3WebView(RsPluginHandler *handler,WebViewNotify *notifier) 88 | : RsPQIService(RS_SERVICE_TYPE_WebView_PLUGIN,0,handler), mWebViewMtx("p3WebView"), mServiceControl(handler->getServiceControl()) , mNotify(notifier) 89 | { 90 | addSerialType(new RsWebViewSerialiser()); 91 | 92 | 93 | //plugin default configuration 94 | 95 | } 96 | RsServiceInfo p3WebView::getServiceInfo() 97 | { 98 | const std::string TURTLE_APP_NAME = "WebView"; 99 | const uint16_t TURTLE_APP_MAJOR_VERSION = 1; 100 | const uint16_t TURTLE_APP_MINOR_VERSION = 0; 101 | const uint16_t TURTLE_MIN_MAJOR_VERSION = 1; 102 | const uint16_t TURTLE_MIN_MINOR_VERSION = 0; 103 | 104 | return RsServiceInfo(RS_SERVICE_TYPE_WebView_PLUGIN, 105 | TURTLE_APP_NAME, 106 | TURTLE_APP_MAJOR_VERSION, 107 | TURTLE_APP_MINOR_VERSION, 108 | TURTLE_MIN_MAJOR_VERSION, 109 | TURTLE_MIN_MINOR_VERSION); 110 | } 111 | 112 | int p3WebView::tick() 113 | { 114 | #ifdef DEBUG_WebView 115 | std::cerr << "ticking p3WebView" << std::endl; 116 | #endif 117 | 118 | //processIncoming(); 119 | //sendPackets(); 120 | 121 | return 0; 122 | } 123 | 124 | int p3WebView::status() 125 | { 126 | return 1; 127 | } 128 | #include 129 | void p3WebView::str_msg_peer(RsPeerId peerID, QString strdata){ 130 | QVariantMap map; 131 | map.insert("type", "chat"); 132 | map.insert("message", strdata); 133 | 134 | qvm_msg_peer(peerID,map); 135 | } 136 | 137 | void p3WebView::qvm_msg_peer(RsPeerId peerID, QVariantMap data){ 138 | QJsonDocument jsondoc = QJsonDocument::fromVariant(data); 139 | std::string msg = jsondoc.toJson().toStdString(); 140 | raw_msg_peer(peerID, msg); 141 | } 142 | void p3WebView::raw_msg_peer(RsPeerId peerID, std::string msg){ 143 | std::cout << "MSging: " << peerID.toStdString() << "\n"; 144 | std::cout << "MSging: " << msg << "\n"; 145 | /* create the packet */ 146 | RsWebViewDataItem *pingPkt = new RsWebViewDataItem(); 147 | pingPkt->PeerId(peerID); 148 | pingPkt->m_msg = msg; 149 | pingPkt->data_size = msg.size(); 150 | //pingPkt->mSeqNo = mCounter; 151 | //pingPkt->mPingTS = convertTsTo64bits(ts); 152 | 153 | //storePingAttempt(*it, ts, mCounter); 154 | 155 | #ifdef DEBUG_WebView 156 | std::cerr << "p3WebView::msg_all() With Packet:"; 157 | std::cerr << std::endl; 158 | pingPkt->print(std::cerr, 10); 159 | #endif 160 | 161 | sendItem(pingPkt); 162 | } 163 | 164 | void p3WebView::msg_all(std::string msg){ 165 | /* we ping our peers */ 166 | //if(!mServiceControl) 167 | // return ; 168 | 169 | //std::set onlineIds; 170 | std::list< RsPeerId > onlineIds; 171 | // mServiceControl->getPeersConnected(getServiceInfo().mServiceType, onlineIds); 172 | rsPeers->getOnlineList(onlineIds); 173 | 174 | double ts = getCurrentTS(); 175 | 176 | #ifdef DEBUG_WebView 177 | std::cerr << "p3WebView::msg_all() @ts: " << ts; 178 | std::cerr << std::endl; 179 | #endif 180 | 181 | std::cout << "READY TO BCast: " << onlineIds.size() << "\n"; 182 | /* prepare packets */ 183 | std::list::iterator it; 184 | for(it = onlineIds.begin(); it != onlineIds.end(); it++) 185 | { 186 | raw_msg_peer(RsPeerId(*it),msg); 187 | } 188 | } 189 | 190 | void p3WebView::ping_all(){ 191 | //TODO ping all! 192 | } 193 | 194 | 195 | 196 | 197 | void p3WebView::handleData(RsWebViewDataItem *item) 198 | { 199 | RsStackMutex stack(mWebViewMtx); /****** LOCKED MUTEX *******/ 200 | 201 | // store the data in a queue. 202 | 203 | //std::cout << "GOT MSG\n"; 204 | /*std::string msg = item->getMessage(); 205 | //std::cout << msg << "\n\n"; 206 | if (msg.substr(0,4).compare("JINT") == 0){ 207 | compatablePeers.insert(item->PeerId().c_str(),msg.c_str()); 208 | return; 209 | }*/ 210 | QVariantMap qDict; 211 | qDict.insert("message",QString(item->m_msg.c_str())); 212 | qDict.insert("peerID",QString(item->PeerId().toStdString().c_str())); 213 | qDict.insert("peerName",QString(rsPeers->getPeerName(item->PeerId()).c_str())); 214 | /*QStringList qMsg; 215 | qMsg.append(QString(item->getMessage().c_str())); 216 | qMsg.append(QString(item->PeerId().c_str())); 217 | qMsg.append(QString(rsPeers->getPeerName(item->PeerId()).c_str()));*/ 218 | eBridge->pushMsgToJs(qDict); 219 | 220 | mNotify->notifyReceivedMsg(item->PeerId(), QString::fromStdString(item->m_msg)); 221 | } 222 | 223 | bool p3WebView::recvItem(RsItem *item) 224 | { 225 | std::cout << "recvItem type: " << item->PacketSubType() << "\n"; 226 | /* pass to specific handler */ 227 | bool keep = false ; 228 | 229 | switch(item->PacketSubType()) 230 | { 231 | case RS_PKT_SUBTYPE_WebView_DATA: 232 | handleData(dynamic_cast(item)); 233 | keep = true ; 234 | break; 235 | 236 | default: 237 | break; 238 | } 239 | 240 | /* clean up */ 241 | if(!keep) 242 | delete item; 243 | return true ; 244 | } 245 | 246 | 247 | 248 | RsTlvKeyValue p3WebView::push_int_value(const std::string& key,int value) 249 | { 250 | RsTlvKeyValue kv ; 251 | kv.key = key ; 252 | rs_sprintf(kv.value, "%d", value); 253 | 254 | return kv ; 255 | } 256 | int p3WebView::pop_int_value(const std::string& s) 257 | { 258 | std::istringstream is(s) ; 259 | 260 | int val ; 261 | is >> val ; 262 | 263 | return val ; 264 | } 265 | 266 | bool p3WebView::saveList(bool& cleanup, std::list& lst) 267 | { 268 | cleanup = true ; 269 | 270 | RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ; 271 | 272 | /*vitem->tlvkvs.pairs.push_back(push_int_value("P3WebView_CONFIG_ATRANSMIT",_atransmit)) ; 273 | vitem->tlvkvs.pairs.push_back(push_int_value("P3WebView_CONFIG_VOICEHOLD",_voice_hold)) ; 274 | vitem->tlvkvs.pairs.push_back(push_int_value("P3WebView_CONFIG_VADMIN" ,_vadmin)) ; 275 | vitem->tlvkvs.pairs.push_back(push_int_value("P3WebView_CONFIG_VADMAX" ,_vadmax)) ; 276 | vitem->tlvkvs.pairs.push_back(push_int_value("P3WebView_CONFIG_NOISE_SUP",_noise_suppress)) ; 277 | vitem->tlvkvs.pairs.push_back(push_int_value("P3WebView_CONFIG_MIN_LOUDN",_min_loudness)) ; 278 | vitem->tlvkvs.pairs.push_back(push_int_value("P3WebView_CONFIG_ECHO_CNCL",_echo_cancel)) ;*/ 279 | 280 | lst.push_back(vitem) ; 281 | 282 | return true ; 283 | } 284 | bool p3WebView::loadList(std::list& load) 285 | { 286 | for(std::list::const_iterator it(load.begin());it!=load.end();++it) 287 | { 288 | #ifdef P3TURTLE_DEBUG 289 | assert(item!=NULL) ; 290 | #endif 291 | RsConfigKeyValueSet *vitem = dynamic_cast(*it) ; 292 | /* 293 | if(vitem != NULL) 294 | for(std::list::const_iterator kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit) 295 | if(kit->key == "P3WebView_CONFIG_ATRANSMIT") 296 | _atransmit = pop_int_value(kit->value) ; 297 | else if(kit->key == "P3WebView_CONFIG_VOICEHOLD") 298 | _voice_hold = pop_int_value(kit->value) ; 299 | else if(kit->key == "P3WebView_CONFIG_VADMIN") 300 | _vadmin = pop_int_value(kit->value) ; 301 | else if(kit->key == "P3WebView_CONFIG_VADMAX") 302 | _vadmax = pop_int_value(kit->value) ; 303 | else if(kit->key == "P3WebView_CONFIG_NOISE_SUP") 304 | _noise_suppress = pop_int_value(kit->value) ; 305 | else if(kit->key == "P3WebView_CONFIG_MIN_LOUDN") 306 | _min_loudness = pop_int_value(kit->value) ; 307 | else if(kit->key == "P3WebView_CONFIG_ECHO_CNCL") 308 | _echo_cancel = pop_int_value(kit->value) ; 309 | 310 | delete vitem ; 311 | */ 312 | } 313 | 314 | return true ; 315 | } 316 | 317 | RsSerialiser *p3WebView::setupSerialiser() 318 | { 319 | RsSerialiser *rsSerialiser = new RsSerialiser(); 320 | rsSerialiser->addSerialType(new RsWebViewSerialiser()); 321 | rsSerialiser->addSerialType(new RsGeneralConfigSerialiser()); 322 | 323 | return rsSerialiser ; 324 | } 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | --------------------------------------------------------------------------------