summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Eefting <edwin@datux.nl>2012-02-23 23:51:01 (GMT)
committer Edwin Eefting <edwin@datux.nl>2012-02-23 23:51:01 (GMT)
commit6603f3fa5cd3149f7583bf24eb5d5e5994219dbf (patch)
tree6e9bad711030b8895b3867eeb84ac2093b62e029
parentdf788cf4df9ef9b565e41b45b6fa75968a7e59e1 (diff)
putting rights stuff in gui
-rw-r--r--modules/docs/html/classpaper_1_1CpaperClient-members.html4
-rw-r--r--modules/docs/html/classpaper_1_1CpaperClient.html27
-rw-r--r--modules/docs/html/functions.html3
-rw-r--r--modules/docs/html/functions_func.html3
-rw-r--r--modules/docs/html/namespacepaper.html22
-rw-r--r--modules/docs/html/paper_8module_2module_8cpp.html2
-rw-r--r--modules/paper.module/cpaperclient.cpp14
-rw-r--r--modules/paper.module/cpaperclient.h6
-rw-r--r--modules/paper.module/cpaperobject.cpp2
-rw-r--r--modules/paper.module/module.cpp19
-rw-r--r--wwwdir/paper/paper.js181
11 files changed, 197 insertions, 86 deletions
diff --git a/modules/docs/html/classpaper_1_1CpaperClient-members.html b/modules/docs/html/classpaper_1_1CpaperClient-members.html
index c04dfe8..790237f 100644
--- a/modules/docs/html/classpaper_1_1CpaperClient-members.html
+++ b/modules/docs/html/classpaper_1_1CpaperClient-members.html
@@ -54,10 +54,12 @@ This is the complete list of members for <a class="el" href="classpaper_1_1Cpape
<tr bgcolor="#f0f0f0"><td><b>mAuthChange</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
<tr bgcolor="#f0f0f0"><td><b>mAuthChat</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
<tr bgcolor="#f0f0f0"><td><b>mAuthCursor</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
+ <tr bgcolor="#f0f0f0"><td><b>mAuthDescription</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
<tr bgcolor="#f0f0f0"><td><b>mAuthOwner</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
<tr bgcolor="#f0f0f0"><td><b>mCursor</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
- <tr bgcolor="#f0f0f0"><td><b>mDescription</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
+ <tr bgcolor="#f0f0f0"><td><b>mInfo</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
<tr bgcolor="#f0f0f0"><td><b>mLastElementId</b> (defined in <a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a>)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
+ <tr class="memlist"><td><a class="el" href="classpaper_1_1CpaperClient.html#a185feb49970e8f19ac40adcc76cb9aee">setInfo</a>(Cvar &amp;var)</td><td><a class="el" href="classpaper_1_1CpaperClient.html">paper::CpaperClient</a></td><td></td></tr>
</table></div>
diff --git a/modules/docs/html/classpaper_1_1CpaperClient.html b/modules/docs/html/classpaper_1_1CpaperClient.html
index 7f938b2..2dbe309 100644
--- a/modules/docs/html/classpaper_1_1CpaperClient.html
+++ b/modules/docs/html/classpaper_1_1CpaperClient.html
@@ -59,12 +59,16 @@ Public Member Functions</h2></td></tr>
void&#160;</td><td class="memItemRight" valign="bottom"><b>authorize</b> (Cvar &amp;rights)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpaper_1_1CpaperClient.html#af3ea075424b1ae21ddf6b2b3bada7e8b">getInfo</a> (Cvar &amp;var)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Fills var with information about the client. <a href="#af3ea075424b1ae21ddf6b2b3bada7e8b"></a><br/></td></tr>
+<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpaper_1_1CpaperClient.html#a185feb49970e8f19ac40adcc76cb9aee">setInfo</a> (Cvar &amp;var)</td></tr>
+<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets info fields of client (can be anything) <a href="#a185feb49970e8f19ac40adcc76cb9aee"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afcee5bd87823211a58d51a2f0a635d35"></a><!-- doxytag: member="paper::CpaperClient::mCursor" ref="afcee5bd87823211a58d51a2f0a635d35" args="" -->
Cvar&#160;</td><td class="memItemRight" valign="bottom"><b>mCursor</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aca6d9f0471f26f88a4baf5d294c0bedf"></a><!-- doxytag: member="paper::CpaperClient::mLastElementId" ref="aca6d9f0471f26f88a4baf5d294c0bedf" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>mLastElementId</b></td></tr>
+<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a95904308b562a1ac9324567a705e3eb2"></a><!-- doxytag: member="paper::CpaperClient::mInfo" ref="a95904308b562a1ac9324567a705e3eb2" args="" -->
+Cvar&#160;</td><td class="memItemRight" valign="bottom"><b>mInfo</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a887e887ecd3978b7b3a7fa45596de96f"></a><!-- doxytag: member="paper::CpaperClient::mAuthCursor" ref="a887e887ecd3978b7b3a7fa45596de96f" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>mAuthCursor</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a10c443887a28ceca1732379797ec1c46"></a><!-- doxytag: member="paper::CpaperClient::mAuthChat" ref="a10c443887a28ceca1732379797ec1c46" args="" -->
@@ -73,8 +77,8 @@ bool&#160;</td><td class="memItemRight" valign="bottom"><b>mAuthChat</b></td></t
bool&#160;</td><td class="memItemRight" valign="bottom"><b>mAuthChange</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab3c89718fc506033f76fb24f0b37a7fa"></a><!-- doxytag: member="paper::CpaperClient::mAuthOwner" ref="ab3c89718fc506033f76fb24f0b37a7fa" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>mAuthOwner</b></td></tr>
-<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abc32ee59149ea6462779b8b5d8fbe261"></a><!-- doxytag: member="paper::CpaperClient::mDescription" ref="abc32ee59149ea6462779b8b5d8fbe261" args="" -->
-string&#160;</td><td class="memItemRight" valign="bottom"><b>mDescription</b></td></tr>
+<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3be0e43f6f7e5453e1531e90a59e0120"></a><!-- doxytag: member="paper::CpaperClient::mAuthDescription" ref="a3be0e43f6f7e5453e1531e90a59e0120" args="" -->
+string&#160;</td><td class="memItemRight" valign="bottom"><b>mAuthDescription</b></td></tr>
<tr><td colspan="2"><h2><a name="friends"></a>
Friends</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a10180dc57a835ca6853b32f523abd27a"></a><!-- doxytag: member="paper::CpaperClient::CpaperObject" ref="a10180dc57a835ca6853b32f523abd27a" args="" -->
@@ -108,6 +112,25 @@ class&#160;</td><td class="memItemRight" valign="bottom"><b>CpaperObject</b></td
</div>
</div>
+<a class="anchor" id="a185feb49970e8f19ac40adcc76cb9aee"></a><!-- doxytag: member="paper::CpaperClient::setInfo" ref="a185feb49970e8f19ac40adcc76cb9aee" args="(Cvar &amp;var)" -->
+<div class="memitem">
+<div class="memproto">
+ <table class="memname">
+ <tr>
+ <td class="memname">void paper::CpaperClient::setInfo </td>
+ <td>(</td>
+ <td class="paramtype">Cvar &amp;&#160;</td>
+ <td class="paramname"><em>var</em></td><td>)</td>
+ <td></td>
+ </tr>
+ </table>
+</div>
+<div class="memdoc">
+
+<p>Sets info fields of client (can be anything) </p>
+
+</div>
+</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>paper.module/cpaperclient.h</li>
<li>paper.module/cpaperclient.cpp</li>
diff --git a/modules/docs/html/functions.html b/modules/docs/html/functions.html
index 9b2002b..af63d44 100644
--- a/modules/docs/html/functions.html
+++ b/modules/docs/html/functions.html
@@ -59,6 +59,9 @@
<li>sendMessage()
: <a class="el" href="classChttpSessionMan.html#aea83ff69806394e39e59944c2014f7a5">ChttpSessionMan</a>
</li>
+<li>setInfo()
+: <a class="el" href="classpaper_1_1CpaperClient.html#a185feb49970e8f19ac40adcc76cb9aee">paper::CpaperClient</a>
+</li>
</ul>
</div>
diff --git a/modules/docs/html/functions_func.html b/modules/docs/html/functions_func.html
index 5b5ba5f..6f4ac9c 100644
--- a/modules/docs/html/functions_func.html
+++ b/modules/docs/html/functions_func.html
@@ -59,6 +59,9 @@
<li>sendMessage()
: <a class="el" href="classChttpSessionMan.html#aea83ff69806394e39e59944c2014f7a5">ChttpSessionMan</a>
</li>
+<li>setInfo()
+: <a class="el" href="classpaper_1_1CpaperClient.html#a185feb49970e8f19ac40adcc76cb9aee">paper::CpaperClient</a>
+</li>
</ul>
</div>
diff --git a/modules/docs/html/namespacepaper.html b/modules/docs/html/namespacepaper.html
index 744dcb5..eee3153 100644
--- a/modules/docs/html/namespacepaper.html
+++ b/modules/docs/html/namespacepaper.html
@@ -67,6 +67,8 @@ synapse::CobjectMan&lt; <a class="el" href="classpaper_1_1CpaperObject.html">Cpa
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to authenticate and join a client to a paper. <a href="#a520f296aae4e37801e38a61caf9175ab"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepaper.html#af8f7818bb1986483d956880a2a719da5">SYNAPSE_REGISTER</a> (paper_ChangeAuth)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Change authentication and authorisation info. <a href="#af8f7818bb1986483d956880a2a719da5"></a><br/></td></tr>
+<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepaper.html#a84c854a4c8949fe58e47c6d31f84f61d">SYNAPSE_REGISTER</a> (paper_ChangeInfo)</td></tr>
+<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Change arbitrary client info (name etc) <a href="#a84c854a4c8949fe58e47c6d31f84f61d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepaper.html#ab49477c33c13bf59bf816f2fa9261589">SYNAPSE_REGISTER</a> (paper_Check)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Client wants to check if the paper exists and credentials are ok TODO: credential stuff. <a href="#ab49477c33c13bf59bf816f2fa9261589"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepaper.html#ae030c4c205681a82b28e67ab946306cb">SYNAPSE_REGISTER</a> (paper_Leave)</td></tr>
@@ -215,6 +217,26 @@ synapse::Cconfig&#160;</td><td class="memItemRight" valign="bottom"><b>gPaperInd
</div>
</div>
+<a class="anchor" id="a84c854a4c8949fe58e47c6d31f84f61d"></a><!-- doxytag: member="paper::SYNAPSE_REGISTER" ref="a84c854a4c8949fe58e47c6d31f84f61d" args="(paper_ChangeInfo)" -->
+<div class="memitem">
+<div class="memproto">
+ <table class="memname">
+ <tr>
+ <td class="memname">paper::SYNAPSE_REGISTER </td>
+ <td>(</td>
+ <td class="paramtype">paper_ChangeInfo&#160;</td>
+ <td class="paramname"></td><td>)</td>
+ <td></td>
+ </tr>
+ </table>
+</div>
+<div class="memdoc">
+
+<p>Change arbitrary client info (name etc) </p>
+<dl class="user"><dt><b>Sends: <em><code>object_Client</code> </em> </b></dt><dd>With new info, filled with <a class="el" href="classpaper_1_1CpaperClient.html#af3ea075424b1ae21ddf6b2b3bada7e8b">CpaperClient::getInfo</a> </dd></dl>
+
+</div>
+</div>
<a class="anchor" id="af8f7818bb1986483d956880a2a719da5"></a><!-- doxytag: member="paper::SYNAPSE_REGISTER" ref="af8f7818bb1986483d956880a2a719da5" args="(paper_ChangeAuth)" -->
<div class="memitem">
<div class="memproto">
diff --git a/modules/docs/html/paper_8module_2module_8cpp.html b/modules/docs/html/paper_8module_2module_8cpp.html
index 7239c1f..1223bda 100644
--- a/modules/docs/html/paper_8module_2module_8cpp.html
+++ b/modules/docs/html/paper_8module_2module_8cpp.html
@@ -80,6 +80,8 @@ synapse::CobjectMan&lt; CpaperObject &gt;&#160;</td><td class="memItemRight" val
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to authenticate and join a client to a paper. <a href="#a520f296aae4e37801e38a61caf9175ab"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepaper.html#af8f7818bb1986483d956880a2a719da5">paper::SYNAPSE_REGISTER</a> (paper_ChangeAuth)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Change authentication and authorisation info. <a href="#af8f7818bb1986483d956880a2a719da5"></a><br/></td></tr>
+<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepaper.html#a84c854a4c8949fe58e47c6d31f84f61d">paper::SYNAPSE_REGISTER</a> (paper_ChangeInfo)</td></tr>
+<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Change arbitrary client info (name etc) <a href="#a84c854a4c8949fe58e47c6d31f84f61d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepaper.html#ab49477c33c13bf59bf816f2fa9261589">paper::SYNAPSE_REGISTER</a> (paper_Check)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Client wants to check if the paper exists and credentials are ok TODO: credential stuff. <a href="#ab49477c33c13bf59bf816f2fa9261589"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepaper.html#ae030c4c205681a82b28e67ab946306cb">paper::SYNAPSE_REGISTER</a> (paper_Leave)</td></tr>
diff --git a/modules/paper.module/cpaperclient.cpp b/modules/paper.module/cpaperclient.cpp
index 04a222c..c095908 100644
--- a/modules/paper.module/cpaperclient.cpp
+++ b/modules/paper.module/cpaperclient.cpp
@@ -31,7 +31,7 @@ namespace paper
mAuthOwner=rights["owner"];
mAuthCursor=rights["cursor"];
mAuthChat=rights["chat"];
- mDescription=rights["description"].str();
+ mAuthDescription=rights["description"].str();
// //inform the client of its new rights
// Cmsg out;
@@ -42,6 +42,15 @@ namespace paper
}
+ /** Sets info fields of client (can be anything)
+ *
+ */
+ void CpaperClient::setInfo(Cvar & var)
+ {
+ mInfo=var;
+ }
+
+
/** Fills var with information about the client.
* \P clientId Id of client
* \P rights.change Set to 1 when client has rights to change drawing.
@@ -53,12 +62,13 @@ namespace paper
*/
void CpaperClient::getInfo(Cvar & var)
{
+ var=mInfo;
var["clientId"]=id;
var["rights"]["change"]=mAuthChange;
var["rights"]["owner"]=mAuthOwner;
var["rights"]["cursor"]=mAuthCursor;
var["rights"]["chat"]=mAuthChat;
- var["rights"]["description"]=mDescription;
+ var["rights"]["description"]=mAuthDescription;
}
}
diff --git a/modules/paper.module/cpaperclient.h b/modules/paper.module/cpaperclient.h
index 73e4458..0e54ae1 100644
--- a/modules/paper.module/cpaperclient.h
+++ b/modules/paper.module/cpaperclient.h
@@ -20,13 +20,15 @@ namespace paper
Cvar mCursor;
int mLastElementId;
+ //arbitrary info field for stuff like name
+ Cvar mInfo;
//authorized functions
bool mAuthCursor;
bool mAuthChat;
bool mAuthChange;
bool mAuthOwner;
- string mDescription;
+ string mAuthDescription;
@@ -41,7 +43,7 @@ namespace paper
void authorize(Cvar & rights);
virtual void getInfo(Cvar & var);
-
+ void setInfo(Cvar & var);
};
}
#endif
diff --git a/modules/paper.module/cpaperobject.cpp b/modules/paper.module/cpaperobject.cpp
index eb26660..7da7f93 100644
--- a/modules/paper.module/cpaperobject.cpp
+++ b/modules/paper.module/cpaperobject.cpp
@@ -500,6 +500,8 @@ namespace paper
if (!getClient(msg.src).mAuthChat)
throw(synapse::runtime_error("You're not allowed to chat"));
+ //TODO: overwrite clientName with real client name
+
//store in chat log for this object
mDrawing["chat"].list().push_back(msg["chat"]);
}
diff --git a/modules/paper.module/module.cpp b/modules/paper.module/module.cpp
index 79a60d6..c4a9489 100644
--- a/modules/paper.module/module.cpp
+++ b/modules/paper.module/module.cpp
@@ -81,12 +81,14 @@ namespace paper
out["event"]= "paper_ClientDraw"; out.send(); //draw something
+
out["event"]= "paper_Export"; out.send(); //export the paper to svg/png
out["event"]= "paper_GetList"; out.send(); //get a list of papers
- out["event"]= "paper_Authenticate"; out.send(); //try authenticate ourselfs with specified key
+// out["event"]= "paper_Authenticate"; out.send(); //try authenticate ourselfs with specified key
out["event"]= "paper_ChangeAuth"; out.send(); //adds or changes authentication keys (only owner can do this offcourse)
+ out["event"]= "paper_ChangeInfo"; out.send(); //change client info
@@ -112,7 +114,7 @@ namespace paper
out["event"]= "paper_List"; out.send(); //list of papers
out["event"]= "paper_AuthWrongKey"; out.send(); //client tried to authenticate with wrong key
- out["event"]= "paper_Authorized"; out.send(); //client is authorized new rights
+// out["event"]= "paper_Authorized"; out.send(); //client is authorized new rights
out.clear();
out.event="core_LoadModule";
@@ -224,6 +226,19 @@ namespace paper
gObjectMan.getObjectByClient(msg.src).changeAuth(msg.src,msg["key"],msg["rights"]);
}
+ /** Change arbitrary client info (name etc)
+ *
+ * \SEND object_Client
+ * With new info, filled with \ref CpaperClient::getInfo
+ */
+ SYNAPSE_REGISTER(paper_ChangeInfo)
+ {
+ gObjectMan.getObjectByClient(msg.src).getClient(msg.src).setInfo(msg);
+ gObjectMan.getObjectByClient(msg.src).sendClientUpdate(msg.src);
+
+ }
+
+
/** Client wants to check if the paper exists and credentials are ok
* TODO: credential stuff
*
diff --git a/wwwdir/paper/paper.js b/wwwdir/paper/paper.js
index 015e9c8..9ad7df6 100644
--- a/wwwdir/paper/paper.js
+++ b/wwwdir/paper/paper.js
@@ -139,6 +139,22 @@ function getUrlId()
return($("head").attr("paperId"));
}
+function updateAuthorisation(newRights)
+{
+ authorized=newRights;
+ //hide/show widgets according to rights
+ if (authorized.change)
+ $("#toolbox").show();
+ else
+ $("#toolbox").hide();
+
+ if (authorized.chat)
+ $("#chatInput").show();
+ else
+ $("#chatInput").hide();
+
+}
+
//reset and prepare for a complete reload of all data
function reset()
{
@@ -162,9 +178,63 @@ function reset()
$(".tool").removeClass('selected');
$(".defaultTool").addClass('selected');
$(".defaultSetting").show();
+
+ updateAuthorisation({
+ owner:0,
+ cursor:0,
+ chat:0,
+ change:0
+ });
}
+//create/get cursor svg object for specified client
+function getCursor(clientId)
+{
+ var cursor=document.getElementById('cursor'+clientId);
+ if (cursor==null)
+ {
+ //create a group for this client's cursor
+ cursor = document.createElementNS(svgns, 'g');
+ cursor.setAttribute('id', 'cursor'+clientId);
+ cursor.setAttribute('stroke', '#000000');
+ cursor.setAttribute('stroke-width', '10');
+ drawing.appendChild(cursor);
+
+ //add drawing to the cursor group
+ var e = document.createElementNS(svgns, 'line');
+ e.setAttribute('x1', '-200');
+ e.setAttribute('x2', '+200');
+ e.setAttribute('y1', '0');
+ e.setAttribute('y2', '0');
+ cursor.appendChild(e);
+
+ var e = document.createElementNS(svgns, 'line');
+ e.setAttribute('x1', '0');
+ e.setAttribute('x2', '0');
+ e.setAttribute('y1', '-200');
+ e.setAttribute('y2', '+200');
+ cursor.appendChild(e);
+
+ //create text element
+ var e = document.createElementNS(svgns, 'text');
+ e.setAttribute('id', 'cursorName'+clientId);
+ e.setAttribute('x', '0');
+ e.setAttribute('y', '300');
+ e.setAttribute('font-size','200');
+ e.setAttribute('font-weight','bold');
+ e.setAttribute('stroke','#000000');
+ e.setAttribute('fill','#000000');
+ cursor.appendChild(e);
+
+ //add the actual text
+ var textNode = document.createTextNode("(unknown)", true);
+ e.appendChild(textNode);
+
+ }
+ return (cursor);
+}
+
/*** Drawing protocol
@@ -200,7 +270,7 @@ beforeId: set by server to the id of the element this element should be insert
normally only set when requesting a refresh.
#### Cursor indication
-cursor: Cursor and name information: x,y,clientName.
+cursor: Cursor and name information: x,y
The server keeps a list of cursors and sends them when a client joins.
### Chat
@@ -328,82 +398,20 @@ function draw(msg)
loading=false;
}
- //update cursor/client name?
+ //update cursor?
if (msg["cursor"]!=null && msg["src"]!=ourId)
{
- var cursor=document.getElementById('cursor'+msg["src"]);
- if (cursor==null)
- {
- //create a group for this client's cursor
- cursor = document.createElementNS(svgns, 'g');
- cursor.setAttribute('id', 'cursor'+msg["src"]);
- cursor.setAttribute('stroke', '#000000');
- cursor.setAttribute('stroke-width', '10');
- drawing.appendChild(cursor);
-
- //add drawing to the cursor group
- var e = document.createElementNS(svgns, 'line');
- e.setAttribute('x1', '-200');
- e.setAttribute('x2', '+200');
- e.setAttribute('y1', '0');
- e.setAttribute('y2', '0');
- cursor.appendChild(e);
-
- var e = document.createElementNS(svgns, 'line');
- e.setAttribute('x1', '0');
- e.setAttribute('x2', '0');
- e.setAttribute('y1', '-200');
- e.setAttribute('y2', '+200');
- cursor.appendChild(e);
-
- //create text element
- var e = document.createElementNS(svgns, 'text');
- e.setAttribute('id', 'clientName'+msg["src"]);
- e.setAttribute('x', '0');
- e.setAttribute('y', '300');
- e.setAttribute('font-size','200');
- e.setAttribute('font-weight','bold');
- e.setAttribute('stroke','#000000');
- e.setAttribute('fill','#000000');
- cursor.appendChild(e);
-
- //add the actual text
- var textNode = document.createTextNode("(unknown)", true);
- e.appendChild(textNode);
-
- }
+ //get/create cursor:
+ var cursor=getCursor(msg["src"]);
//update cursor position?
if (msg["cursor"]["x"]!=null)
{
cursor.setAttribute('transform', 'translate('+msg["cursor"]["x"]+','+msg["cursor"]["y"]+')');
}
-
- //update cursor clientname?
- if (msg["cursor"]["clientName"]!=null)
- {
- //update cursor text:
- var e=document.getElementById('clientName'+msg["src"]);
- e.childNodes[0].data=filterInput(msg["cursor"]["clientName"],15);
- }
}
- //update chat client list
- if (msg["cursor"]!=null && msg["cursor"]["clientName"]!=null)
- {
- var clientName=filterInput(msg["cursor"]["clientName"],15);
-
- var e=document.getElementById('chatClient'+msg["src"]);
- if (e==null)
- {
- $("#chatClients").append("<div id='chatClient"+msg["src"]+"' class='chatClient'>"+clientName+"</div>");
- chatPrintOnline();
- }
- else
- e.childNodes[0].data=clientName;
-
- }
//received chat text?
if (msg["chat"] != null)
@@ -521,8 +529,11 @@ function mouseMove(force)
var c=toServer(mousePoint.x,mousePoint.y);
var msg={};
- //cursor
- msg['cursor']=c;
+ //cursor authorized?
+ if (authorized.cursor)
+ msg['cursor']=c;
+ else
+ return; //no? then we may not do anything
if (mouseMode=="polyline")
{
@@ -615,6 +626,9 @@ function mouseMove(force)
//user starts a mouse operation (clicks somewhere)
function mouseStart(m)
{
+ if (!authorized.change)
+ return;
+
if (mousePoint.x==null || mousePoint.y==null)
return;
tempCount++;
@@ -826,12 +840,9 @@ synapse_register("module_SessionStart",function(msg_src, msg_dst, msg_event, msg
$("#chatClientName").keyup(function(m)
{
$.setCookie('clientName', $("#chatClientName").val(), { duration:365, path:"/" });
- sendDraw({
- 'cursor':{
- 'clientName':$("#chatClientName").val()
- }
- });
-
+ send(paperModId,"paper_ChangeInfo", {
+ name: $("#chatClientName").val()
+ });
});
//user presses enter in chatInput:
@@ -1168,7 +1179,7 @@ synapse_register("module_SessionStart",function(msg_src, msg_dst, msg_event, msg
if (msg_dst==msg["clientId"])
{
//store rights in global array for easy access
- authorized=msg["rights"];
+ updateAuthorisation(msg["rights"]);
// if (authorized["cursor"])
// {
// //tell people who we are and set random mouse position
@@ -1184,8 +1195,24 @@ synapse_register("module_SessionStart",function(msg_src, msg_dst, msg_event, msg
// });
}
-
- //TODO:update client list
+
+ var name=filterInput(msg.name,15);
+
+ //update cursor text, if it exists
+ var e=document.getElementById('cursorName'+msg.clientId);
+ if (e)
+ e.childNodes[0].data=filterInput(name,15);
+
+ //update chat client list
+ var e=document.getElementById('chatClient'+msg.clientId);
+ if (e==null)
+ {
+ $("#chatClients").append("<div id='chatClient"+msg.clientId+"' class='chatClient'>"+name+"</div>");
+ chatPrintOnline();
+ }
+ else
+ e.childNodes[0].data=name;
+
});
//we've joined a object