[Libreoffice-commits] core.git: ios/experimental

jan Iversen jani at libreoffice.org
Sun Mar 19 21:28:02 UTC 2017


 ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj |    4 
 ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift                  |   10 
 ios/experimental/LibreOfficeLight/LibreOfficeLight/WebView.swift             |   14 
 ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard  |   17 
 ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h   |    4 
 ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c                   |  205 ++++++----
 6 files changed, 173 insertions(+), 81 deletions(-)

New commits:
commit 941ef397e9267f7ca7fac8b2133272f3655ec460
Author: jan Iversen <jani at libreoffice.org>
Date:   Thu Mar 2 16:38:41 2017 +0100

    ios LibreOfficeLight, tokenize
    
    Add general tokenizer for parameters.
    and WebWiew to host JS from online
    
    Change-Id: I5bb419c18d239d6d88fa17078c079420aac58931
    Reviewed-on: https://gerrit.libreoffice.org/35438
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: jan iversen <jani at libreoffice.org>

diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj b/ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj
index ab3e6af22da1..44d84f4028e9 100644
--- a/ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj
+++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj
@@ -21,6 +21,7 @@
 		3992D85E1E5B764A00BEA987 /* ViewFileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3992D85C1E5B764A00BEA987 /* ViewFileManager.swift */; };
 		399648471E5B87DC00E73E83 /* ViewProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 399648461E5B87DC00E73E83 /* ViewProperties.swift */; };
 		399648491E5C4E5500E73E83 /* LO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 399648481E5C4E5500E73E83 /* LO.swift */; };
+		399BA3721E6881FC003D74A6 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 399BA3711E6881FC003D74A6 /* WebView.swift */; };
 		39A83A8F1E5F471D00D0C683 /* lokit.c in Sources */ = {isa = PBXBuildFile; fileRef = 39A83A8E1E5F471D00D0C683 /* lokit.c */; };
 		39B084E31E5F0A9600682A59 /* lo.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; };
 		39B08B9D1E5F0BB600682A59 /* fundamentalrc in Resources */ = {isa = PBXBuildFile; fileRef = 39B084E51E5F0BB400682A59 /* fundamentalrc */; };
@@ -72,6 +73,7 @@
 		3992D85C1E5B764A00BEA987 /* ViewFileManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ViewFileManager.swift; path = LibreOfficeLight/ViewFileManager.swift; sourceTree = SOURCE_ROOT; };
 		399648461E5B87DC00E73E83 /* ViewProperties.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ViewProperties.swift; path = LibreOfficeLight/ViewProperties.swift; sourceTree = SOURCE_ROOT; };
 		399648481E5C4E5500E73E83 /* LO.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LO.swift; path = LibreOfficeLight/LO.swift; sourceTree = SOURCE_ROOT; };
+		399BA3711E6881FC003D74A6 /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = "<group>"; };
 		39A83A8D1E5F471C00D0C683 /* lokit-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; name = "lokit-Bridging-Header.h"; path = "LibreOfficeLight/lokit-Bridging-Header.h"; sourceTree = SOURCE_ROOT; };
 		39A83A8E1E5F471D00D0C683 /* lokit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lokit.c; path = LibreOfficeLight/lokit.c; sourceTree = SOURCE_ROOT; };
 		39B084E21E5F0A9600682A59 /* lo.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = lo.xcconfig; path = "../../../../ios-work/workdir/ios/generated/lo.xcconfig"; sourceTree = SOURCE_ROOT; };
@@ -162,6 +164,7 @@
 				397E09011E597BD8001374E0 /* Main.storyboard */,
 				397868D81E59A3EA007F9248 /* LaunchScreen.xib */,
 				39A83A8D1E5F471C00D0C683 /* lokit-Bridging-Header.h */,
+				399BA3711E6881FC003D74A6 /* WebView.swift */,
 			);
 			path = LibreOfficeLight;
 			sourceTree = SOURCE_ROOT;
@@ -354,6 +357,7 @@
 				39A83A8F1E5F471D00D0C683 /* lokit.c in Sources */,
 				399648491E5C4E5500E73E83 /* LO.swift in Sources */,
 				3992D8581E5B761700BEA987 /* ViewController.swift in Sources */,
+				399BA3721E6881FC003D74A6 /* WebView.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift b/ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift
index 91f344169afa..c07071081f33 100755
--- a/ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift
+++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift
@@ -23,8 +23,14 @@ class LOkit
 
     func Initialize()
     {
-        LOkit_ClientCommand()
-    }
+        let myInput = "ping command jan var her"
+        
+        LOkit_ClientCommand(myInput)
+
+        let my2Input = "mouse command jan var her"
+        
+        LOkit_ClientCommand(my2Input)
+}
     
     func DeleteCurrentDocument()
     {
diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/WebView.swift b/ios/experimental/LibreOfficeLight/LibreOfficeLight/WebView.swift
new file mode 100644
index 000000000000..f257174be978
--- /dev/null
+++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/WebView.swift
@@ -0,0 +1,14 @@
+//
+// This file is part of the LibreOffice project.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+//
+import WebKit
+
+
+
+class WebView: UIWebView {
+}
+
diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard b/ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard
index ca8bcc1855e9..5c1ae778091c 100755
--- a/ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard
+++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard
@@ -22,15 +22,18 @@
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                         <subviews>
-                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="My Document" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UR6-NA-Ecz">
-                                <rect key="frame" x="177" y="495" width="128" height="21"/>
-                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                <nil key="textColor"/>
-                                <nil key="highlightedColor"/>
-                            </label>
+                            <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1Ej-ex-Oyr" customClass="WebView" customModule="LibreOfficeLight">
+                                <rect key="frame" x="16" y="64" width="343" height="559"/>
+                                <color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                            </webView>
                         </subviews>
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <constraints>
+                            <constraint firstItem="uE0-fS-86O" firstAttribute="top" secondItem="1Ej-ex-Oyr" secondAttribute="bottom" id="22v-Sf-uWf"/>
+                            <constraint firstAttribute="trailingMargin" secondItem="1Ej-ex-Oyr" secondAttribute="trailing" id="2Wt-Tn-erC"/>
+                            <constraint firstItem="1Ej-ex-Oyr" firstAttribute="top" secondItem="lZa-u5-V0W" secondAttribute="bottom" id="jzQ-1h-4Ni"/>
+                            <constraint firstItem="1Ej-ex-Oyr" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="vT5-Un-8bf"/>
+                        </constraints>
                     </view>
                     <toolbarItems/>
                     <navigationItem key="navigationItem" title="Document" id="5c6-32-T4J">
diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h b/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h
index c0f2e204bf83..78ebbe7ee288 100644
--- a/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h
+++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h
@@ -8,6 +8,6 @@
 
 
 // Bridge functions to LibreOfficeKit
-int  LOkit_Init();
-int LOkit_ClientCommand();
+int LOkit_Init();
+int LOkit_ClientCommand(const char *input);
 
diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c b/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c
index 6be800567f26..94143d1cfdd7 100755
--- a/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c
+++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c
@@ -117,7 +117,7 @@ extern "C" void lo_initialize(NSString *documentPath)
 
 
 // CLIENT COMMAND INTERFACE
-static bool client_canceltiles(char *input, char *args[])
+static bool client_canceltiles(const char *args[])
 {
     // command:   canceltiles
     // arguments: NONE
@@ -130,17 +130,19 @@ static bool client_canceltiles(char *input, char *args[])
     return true;
 }
 
-static bool client_clientvisiblearea(char *input, char *args[])
+static bool client_clientvisiblearea(const char *args[])
 {
     // command:   clientvisiblearea
     // arguments: x=<x>
     //            y=<y>
     //            width=<width>
     //            height=<height>
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_closedocument(char *input, char *args[])
+static bool client_closedocument(const char *args[])
 {
     // command:   closedocument
     // arguments: None
@@ -149,17 +151,21 @@ static bool client_closedocument(char *input, char *args[])
     //     currently having that document opened. This functionality is enabled
     //     only in case WOPI. host mentions 'EnableOwnerTermination' flag in
     //     its CheckFileInfo response
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_commandvalues(char *input, char *args[])
+static bool client_commandvalues(const char *args[])
 {
     // command:   commandvalues
     // arguments: None
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_downloadas(char *input, char *args[])
+static bool client_downloadas(const char *args[])
 {
     // command:   downloadas
     // arguments: name=<fileName>
@@ -173,10 +179,12 @@ static bool client_downloadas(char *input, char *args[])
     //         * 'print': When request for download is basically for print purposes
     //         * 'slideshow': When request for download is for showing slideshow
     //         * 'export': Just a simple download
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_getchildid(char *input, char *args[])
+static bool client_getchildid(const char *args[])
 {
     // command:   getchildid
     // arguments: None
@@ -186,16 +194,18 @@ static bool client_getchildid(char *input, char *args[])
     return true;
 }
 
-static bool client_gettextselection(char *input, char *args[])
+static bool client_gettextselection(const char *args[])
 {
     // command:   gettextselection
     // arguments: None
     // description:
     //     Request selection's content
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_insertfile(char *input, char *args[])
+static bool client_insertfile(const char *args[])
 {
     // command:   insertfile
     // arguments: name=<name>
@@ -203,10 +213,12 @@ static bool client_insertfile(char *input, char *args[])
     // description:
     //     Inserts the file with the name <name> into the document,
     //     we currently support type = 'graphic'
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_key(char *input, char *args[])
+static bool client_key(const char *args[])
 {
     // command:   key
     // arguments: type=<type>
@@ -214,10 +226,12 @@ static bool client_key(char *input, char *args[])
     //            key=<keycode>
     // description:
     //     <type> is 'input' or 'up', <charcode> and <keycode> are numbers.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_load(char *input, char *args[])
+static bool client_load(const char *args[])
 {
     // command:   load
     // arguments: [part=<partNumber>]
@@ -230,10 +244,12 @@ static bool client_load(char *input, char *args[])
     //     microseconds since the Unix epoch - midnight, January 1, 1970.
     //     options are the whole rest of the line, not URL-encoded,
     //     and must be valid JSON.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_loolclient(char *input, char *args[])
+static bool client_loolclient(const char *args[])
 {
     // command:   loolclient
     // arguments: <major.minor[-patch]>
@@ -245,10 +261,12 @@ static bool client_loolclient(char *input, char *args[])
     //     Minor: an integer is more flexible and is at the discretion of either party.
     //     Security fixes that do not alter the API would bump the minor version number.
     //     Patch: an optional string that is informational.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_mouse(char *input, char *args[])
+static bool client_mouse(const char *args[])
 {
     // command:   mouse
     // arguments: type=<type>
@@ -257,29 +275,35 @@ static bool client_mouse(char *input, char *args[])
     //            count=<count>
     // description:
     //     <type> is 'buttondown', 'buttonup' or 'move', others are numbers.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_paste(char *input, char *args[])
+static bool client_paste(const char *args[])
 {
     // command:   paste
     // arguments: mimetype=<mimeType>
     //            <binaryPasteData>
     // description:
     //     Paste content at the current cursor position
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_ping(char *input, char *args[])
+static bool client_ping(const char *args[])
 {
     // command:  ping
     // argument: None
     // description:
     //     requests a 'pong' server message.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_renderfont(char *input, char *args[])
+static bool client_renderfont(const char *args[])
 {
     // command:   renderfont
     // arguments: font=<font>
@@ -288,27 +312,33 @@ static bool client_renderfont(char *input, char *args[])
     //     requests the rendering of the given font.
     //     The font parameter is URL encoded
     //     The char parameter is URL encoded
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_requestloksession(char *input, char *args[])
+static bool client_requestloksession(const char *args[])
 {
     // command:   requestloksession
     // arguments: None
     // description:
     //     requests the initialization of a LOK process in an attempt
     //     to predict the user's interaction with the document
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_resetselection(char *input, char *args[])
+static bool client_resetselection(const char *args[])
 {
     // command:   resetselection
     // arguments: None
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_saveas(char *input, char *args[])
+static bool client_saveas(const char *args[])
 {
     // command:   saveas
     // arguments: url=<url>
@@ -318,10 +348,12 @@ static bool client_saveas(char *input, char *args[])
     //     <url> is a URL, encoded. <format> is also URL-encoded,
     //     i.e. spaces as %20 and it can be empty
     //     options are the whole rest of the line, not URL-encoded, and can be empty
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_selectgraphic(char *input, char *args[])
+static bool client_selectgraphic(const char *args[])
 {
     // command:   selectgraphic
     // arguments: type=<type>
@@ -329,10 +361,12 @@ static bool client_selectgraphic(char *input, char *args[])
     //            y=<y>
     // description:
     //     <type> is 'start' or 'end'. <x> and <y> are numbers.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_selecttext(char *input, char *args[])
+static bool client_selecttext(const char *args[])
 {
     // command:   selecttext
     // arguments: type=<type>
@@ -340,33 +374,41 @@ static bool client_selecttext(char *input, char *args[])
     //            y=<y>
     // description:
     //     <type> is 'start', 'end' or 'reset', <x> and <y> are numbers.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_setclientpart(char *input, char *args[])
+static bool client_setclientpart(const char *args[])
 {
     // command:   setclientpart
     // arguments: part=<partNumber>
     // description:
     //     Informs the server that the client changed to part <partNumber>.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_status(char *input, char *args[])
+static bool client_status(const char *args[])
 {
     // command:   status
     // arguments: None
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_styles(char *input, char *args[])
+static bool client_styles(const char *args[])
 {
     // command:   styles
     // arguments: None
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_tile(char *input, char *args[])
+static bool client_tile(const char *args[])
 {
     // command:   tile
     // arguments: part=<partNumber>
@@ -389,10 +431,14 @@ static bool client_tile(char *input, char *args[])
     //     previews of presentation documents, and not for anything else. It
     //     is only useful to loleaflet and will break it if not returned in
     //     the response.
+
+    // JIX MISSING CODE
+
+    // renderTile
     return true;
 }
 
-static bool client_tilecombine(char *input, char *args[])
+static bool client_tilecombine(const char *args[])
 {
     // command:   tilecombine
     // arguments: <parameters>
@@ -401,19 +447,25 @@ static bool client_tilecombine(char *input, char *args[])
     //     parameters 'tileposx', 'tileposy' and 'oldhash' are
     //     comma-separated lists, and the number of elements in each
     //     must be same.
+
+    // JIX MISSING CODE
+
+    // renderCombinedTiles
     return true;
 }
 
-static bool client_uno(char *input, char *args[])
+static bool client_uno(const char *args[])
 {
     // command:   uno
     // arguments: <command>
     // description:
     //     <command> is a line of text.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_useractive(char *input, char *args[])
+static bool client_useractive(const char *args[])
 {
     // command:   useractive
     // arguments: None
@@ -422,10 +474,12 @@ static bool client_useractive(char *input, char *args[])
     //     area to disable the inactive state.
     //     Will send invalidation and update notifications to force refreshing the screen.
     //     See 'userinactive'.
+
+    // JIX MISSING CODE
     return true;
 }
 
-static bool client_userinactive(char *input, char *args[])
+static bool client_userinactive(const char *args[])
 {
     // command:   userinactive
     // arguments: None
@@ -433,67 +487,78 @@ static bool client_userinactive(char *input, char *args[])
     //     Sent when the user has switched tabs or away from the Browser
     //     altogether. It should throttle updates until the user is active again.
     //     See 'useractive'.
+
+    // JIX MISSING CODE
     return true;
 }
 
 
 
-typedef struct {const char *command; bool (*funcCmd)(char *, char *[]);} CLIENTCOMMAND;
-static CLIENTCOMMAND clientcommands[] = {{"canceltiles",       client_canceltiles},
-                                         {"clientvisiblearea", client_clientvisiblearea},
-                                         {"closedocument",     client_closedocument},
-                                         {"commandvalues",     client_commandvalues},
-                                         {"downloadas",        client_downloadas},
-                                         {"getchildid",        client_getchildid},
-                                         {"gettextselection",  client_gettextselection},
-                                         {"insertfile",        client_insertfile},
-                                         {"key",               client_key},
-                                         {"load",              client_load},
-                                         {"loolclient",        client_loolclient},
-                                         {"mouse",             client_mouse},
-                                         {"paste",             client_paste},
-                                         {"ping",              client_ping},
-                                         {"renderfont",        client_renderfont},
-                                         {"requestloksession", client_requestloksession},
-                                         {"resetselection",    client_resetselection},
-                                         {"saveas",            client_saveas},
-                                         {"selectgraphic",     client_selectgraphic},
-                                         {"selecttext",        client_selecttext},
-                                         {"setclientpart",     client_setclientpart},
-                                         {"status",            client_status},
-                                         {"styles",            client_styles},
-                                         {"tile",              client_tile},
-                                         {"tilecombine",       client_tilecombine},
-                                         {"uno",               client_uno},
-                                         {"useractive",        client_useractive},
-                                         {"userinactive",      client_userinactive},
-                                         {NULL,                NULL}
+typedef struct {const char *command; bool useArgs; bool (*funcCmd)(const char *[]);} CLIENTCOMMAND;
+static CLIENTCOMMAND clientcommands[] = {{"canceltiles",       false, client_canceltiles},
+                                         {"clientvisiblearea", true,  client_clientvisiblearea},
+                                         {"closedocument",     false, client_closedocument},
+                                         {"commandvalues",     false, client_commandvalues},
+                                         {"downloadas",        true,  client_downloadas},
+                                         {"getchildid",        false, client_getchildid},
+                                         {"gettextselection",  false, client_gettextselection},
+                                         {"insertfile",        true,  client_insertfile},
+                                         {"key",               true,  client_key},
+                                         {"load",              true,  client_load},
+                                         {"loolclient",        true,  client_loolclient},
+                                         {"mouse",             true,  client_mouse},
+                                         {"paste",             true,  client_paste},
+                                         {"ping",              false, client_ping},
+                                         {"renderfont",        true,  client_renderfont},
+                                         {"requestloksession", false, client_requestloksession},
+                                         {"resetselection",    false, client_resetselection},
+                                         {"saveas",            true,  client_saveas},
+                                         {"selectgraphic",     true,  client_selectgraphic},
+                                         {"selecttext",        true,  client_selecttext},
+                                         {"setclientpart",     true,  client_setclientpart},
+                                         {"status",            false, client_status},
+                                         {"styles",            false, client_styles},
+                                         {"tile",              true,  client_tile},
+                                         {"tilecombine",       true,  client_tilecombine},
+                                         {"uno",               false, client_uno},
+                                         {"useractive",        false, client_useractive},
+                                         {"userinactive",      false, client_userinactive},
+                                         {NULL,                false, NULL}
                                         };
 
 
 
 
-int LOkit_ClientCommand()
+int LOkit_ClientCommand(const char *input)
 {
-    char *args[10];
-    char *sep = " ";
-    char *cmd, *token;
-    char *input = "unknown command jan var her";
+    static char argStore[2048];
+    const char *args[10];
+    char *cmd, *arg;
+    const char *sep = " ";
     int   j = 0;
 
     // Split input into cmd + args
-    token = cmd = strtok(input, sep);
-    while (token && j < 10 && token - input < 2048)
-      args[j++] = token = strtok(token, sep);
+    strcpy(argStore, input);
+    arg = cmd = strtok(argStore, sep);
 
     // Locate correct command
     CLIENTCOMMAND *client_cmd = clientcommands;
-    for (; client_cmd->command; ++cmd)
-        if (!strcmp(client_cmd->command,"mycommand"))
-            return client_cmd->funcCmd(input, NULL);
+    for (; client_cmd->command; ++client_cmd)
+        if (!strcmp(client_cmd->command,cmd)) {
+            args[j++] = input;
+            args[j] = NULL;
+            if (client_cmd->useArgs)
+                while (arg && j < 10)
+                {
+                    arg = strtok(NULL, sep);
+                    args[j++] = arg;
+                }
+            return (int)client_cmd->funcCmd(args);
+        }
+
 
     // Call/Return from command
-    return 0;
+    return -999;
 }
 
 


More information about the Libreoffice-commits mailing list