Skip to content

Commit

Permalink
EranMes: Merging a library for management of IME engines, contributed…
Browse files Browse the repository at this point in the history
… by Timothe Faudot. Next step is to merge the integration with the FirefoxDriver

r11610
  • Loading branch information
eranmes committed Mar 7, 2011
1 parent 2c4c92f commit 1f94960
Show file tree
Hide file tree
Showing 17 changed files with 1,481 additions and 0 deletions.
16 changes: 16 additions & 0 deletions WebDriver.sln
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Selenium.Core.Tests", "dotn
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Selenium.WebDriverBackedSelenium.Tests", "dotnet\test\Selenium.WebDriverBackedSelenium.Tests\Selenium.WebDriverBackedSelenium.Tests.csproj", "{68CF4628-4148-4627-ACA1-D4C225365D3F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imehandler", "cpp\imehandler\imehandler.vcproj", "{37F9EF6B-F69C-4764-9687-C63C608C476B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
Expand Down Expand Up @@ -430,6 +432,20 @@ Global
{68CF4628-4148-4627-ACA1-D4C225365D3F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{68CF4628-4148-4627-ACA1-D4C225365D3F}.Release|Win32.ActiveCfg = Release|Any CPU
{68CF4628-4148-4627-ACA1-D4C225365D3F}.Release|x64.ActiveCfg = Release|Any CPU
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Debug|.NET.ActiveCfg = Debug|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Debug|Any CPU.ActiveCfg = Debug|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Debug|Win32.ActiveCfg = Debug|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Debug|Win32.Build.0 = Debug|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Debug|x64.ActiveCfg = Debug|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Release|.NET.ActiveCfg = Release|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Release|Any CPU.ActiveCfg = Release|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Release|Mixed Platforms.Build.0 = Release|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Release|Win32.ActiveCfg = Release|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Release|Win32.Build.0 = Release|Win32
{37F9EF6B-F69C-4764-9687-C63C608C476B}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
19 changes: 19 additions & 0 deletions cpp/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ gcc_library(name = "noblur64",
srcs = [ "linux-specific/*.c" ],
arch = "amd64")

gcc_library(name = "imehandler",
srcs = [ "imehandler/linux/src/*.cpp" ],
args = "-rdynamic -I cpp/imehandler/common `pkg-config gtk+-2.0 ibus-1.0 --cflags`",
link_args = "`pkg-config gtk+-2.0 ibus-1.0 --libs`",
arch = "i386")

gcc_library(name = "imehandler64",
srcs = [ "imehandler/linux/src/*.cpp" ],
args = "-rdynamic -I cpp/imehandler/common `pkg-config gtk+-2.0 ibus-1.0 --cflags`",
link_args = "`pkg-config gtk+-2.0 ibus-1.0 --libs`",
arch = "amd64")

visualc_library(name = "imehandler_dll",
platform = "Win32",
solution = "WebDriver.sln",
target = "imehandler",
out = "Win32/Release/imehandler.dll"
)

visualc_library(name = "ie_win32_dll",
deps = [
":ie_result_type_cpp",
Expand Down
85 changes: 85 additions & 0 deletions cpp/imehandler/common/imehandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Copyright 2011 WebDriver committers
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: timothe@google.com
*/


#ifndef IMEHANDLER_H_
#define IMEHANDLER_H_

#include <vector>
#include <string>

// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations of all subclasses.
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)


/*
* Abstract class representing a IME handler
* aka. the base class abstracting interactions for all IME on all systems.
*/
class ImeHandler {
public:
virtual ~ImeHandler() {}
/*
* Return the currently installed engines in a clear, human readable
* representation.
*/
virtual std::vector<std::string> GetInstalledEngines() const = 0;

/*
* Return a list of all the available engines on the system.
*/
virtual std::vector<std::string> GetAvailableEngines() const = 0;

/*
* Return a human readable representation of the currently active engine.
*/
virtual std::string GetActiveEngine() const = 0;

/*
* Returns true if a non standard (aka. complex, IME type) input method
* is currently used.
*/
virtual bool IsActivated() const = 0;

/*
* Switches back to a standard input method.
*/
virtual void Deactivate() = 0;

/*
* Load engines in the system.
* Returns the number of loaded engines.
*/
virtual int LoadEngines(const std::vector<std::string>& engines) = 0;

/*
* Sets the specified engine to be the one active.
* Returns true if set correctly, false otherwise.
*/
virtual bool ActivateEngine(const std::string& engine) = 0;
};

/* To use the library with dlopen. */
typedef ImeHandler* create_h();
typedef void destroy_h(ImeHandler*);

#endif // IMEHANDLER_H_
50 changes: 50 additions & 0 deletions cpp/imehandler/common/imeutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2011 WebDriver committers
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: timothe@google.com
*/

#ifndef IMEUTILS_H_
#define IMEUTILS_H_

#include <string>
#include <map>

// A macro to disallow the copy constructor and operator= functions.
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)


class ImeUtils {
public:
virtual ~ImeUtils() {}
std::string GetNextCandidateKeyForEngine(std::string engine) const {
std::string key = "";
std::map<std::string, std::string>::const_iterator it;
if ((it = kNextCandidateKeysMap.find(engine)) !=
kNextCandidateKeysMap.end()) {
key = it->second;
}
return key;
}

protected:
ImeUtils() {}
std::map<std::string, std::string> kNextCandidateKeysMap;
};

#endif // IMEUTILS_H_
Loading

0 comments on commit 1f94960

Please sign in to comment.