From 786387212315152aea0518a493dbd71e3c5a00e3 Mon Sep 17 00:00:00 2001
From: Murai Takashi <tmurai01@gmail.com>
Date: Sat, 26 Oct 2013 06:32:36 +0900
Subject: [PATCH 2/2] CannaIM:copy data files to user setting directory.
---
.../input_server/methods/canna/CannaLooper.cpp | 58 ++++++++++++++++----
.../input_server/methods/canna/CannaLooper.h | 1 +
src/add-ons/input_server/methods/canna/Jamfile | 2 +-
3 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/src/add-ons/input_server/methods/canna/CannaLooper.cpp b/src/add-ons/input_server/methods/canna/CannaLooper.cpp
index 4fbfa50..86b5c40 100644
a
|
b
|
|
8 | 8 | |
9 | 9 | #include "CannaLooper.h" |
10 | 10 | |
11 | | #include <string.h> |
12 | | |
13 | | #include <Debug.h> |
14 | | |
15 | 11 | #include <Alert.h> |
| 12 | #include <Debug.h> |
| 13 | #include <Entry.h> |
16 | 14 | #include <FindDirectory.h> |
17 | 15 | #include <Input.h> |
18 | 16 | #include <Menu.h> |
19 | 17 | #include <MenuItem.h> |
20 | 18 | #include <Messenger.h> |
21 | 19 | #include <Path.h> |
| 20 | #include <PathFinder.h> |
22 | 21 | #include <Screen.h> |
| 22 | #include <string.h> |
| 23 | |
| 24 | #include <CopyEngine.h> |
23 | 25 | |
24 | 26 | #include "CannaCommon.h" |
25 | 27 | #include "CannaMethod.h" |
… |
… |
CannaLooper::CannaLooper(CannaMethod* method)
|
44 | 46 | fMenu->AddItem(new BMenuItem("Reload Init file", |
45 | 47 | new BMessage(RELOAD_INIT_FILE))); |
46 | 48 | |
| 49 | font_family family; |
| 50 | font_style style; |
| 51 | strcpy(family, "VL PGothic"); |
| 52 | strcpy(style, "regular"); |
| 53 | |
| 54 | fKouhoFont.SetFamilyAndStyle(family, style); |
| 55 | fKouhoFont.SetSize(12); |
| 56 | |
47 | 57 | if (gSettings.convert_arrowkey) { |
48 | 58 | BMenuItem* item = fMenu->FindItem(ARROW_KEYS_FLIPPED); |
49 | 59 | item->SetMarked(true); |
… |
… |
CannaLooper::Quit()
|
95 | 105 | |
96 | 106 | |
97 | 107 | status_t |
| 108 | CannaLooper::_CopyData(const char* dstPath) |
| 109 | { |
| 110 | status_t status; |
| 111 | BPath srcPath; |
| 112 | |
| 113 | // Use BPathFinder() and BPathFinder(B_CURRENT_IMAGE_SYMBOL) |
| 114 | // so that users can use either add-on or package. |
| 115 | status = BPathFinder().FindPath( |
| 116 | B_FIND_PATH_DATA_DIRECTORY, "Canna", |
| 117 | B_FIND_PATH_EXISTING_ONLY, srcPath); |
| 118 | if (status != B_OK) { |
| 119 | status = BPathFinder(B_CURRENT_IMAGE_SYMBOL).FindPath( |
| 120 | B_FIND_PATH_DATA_DIRECTORY, "Canna", |
| 121 | B_FIND_PATH_EXISTING_ONLY, srcPath); |
| 122 | if (status != B_OK) |
| 123 | return B_ERROR; |
| 124 | } |
| 125 | BCopyEngine CopyEngine(BCopyEngine::COPY_RECURSIVELY); |
| 126 | status = CopyEngine.CopyEntry(srcPath.Path(), dstPath); |
| 127 | if (status != B_OK) |
| 128 | return B_ERROR; |
| 129 | |
| 130 | return B_OK; |
| 131 | } |
| 132 | |
| 133 | |
| 134 | status_t |
98 | 135 | CannaLooper::ReadSettings(char* basePath) |
99 | 136 | { |
100 | 137 | BPath path; |
101 | | status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path); |
| 138 | status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path); |
102 | 139 | if (status != B_OK) |
103 | 140 | return status; |
104 | 141 | |
… |
… |
CannaLooper::ReadSettings(char* basePath)
|
107 | 144 | strlcpy(basePath, path.Path(), B_PATH_NAME_LENGTH); |
108 | 145 | strlcat(basePath, "/", B_PATH_NAME_LENGTH); |
109 | 146 | |
110 | | font_family family; |
111 | | font_style style; |
112 | | strcpy(family, "VL PGothic"); |
113 | | strcpy(style, "regular"); |
114 | | |
115 | | fKouhoFont.SetFamilyAndStyle(family, style); |
116 | | fKouhoFont.SetSize(12); |
| 147 | BEntry ent(path.Path()); |
| 148 | if (!ent.Exists()) { |
| 149 | return _CopyData(path.Path()); |
| 150 | } |
117 | 151 | |
118 | 152 | return B_OK; |
119 | 153 | } |
diff --git a/src/add-ons/input_server/methods/canna/CannaLooper.h b/src/add-ons/input_server/methods/canna/CannaLooper.h
index 60e93a3..ad45523 100644
a
|
b
|
public:
|
38 | 38 | void SendInputStarted(); |
39 | 39 | |
40 | 40 | private: |
| 41 | status_t _CopyData(const char* dstPath); |
41 | 42 | void _HandleKeyDown(BMessage* msg); |
42 | 43 | void _HandleLocationReply(BMessage* msg); |
43 | 44 | void _HandleMethodActivated(bool active); |
diff --git a/src/add-ons/input_server/methods/canna/Jamfile b/src/add-ons/input_server/methods/canna/Jamfile
index 59c7050..211008a 100644
a
|
b
|
SubDir HAIKU_TOP src add-ons input_server methods canna ;
|
2 | 2 | |
3 | 3 | SetSubDirSupportedPlatformsBeOSCompatible ; |
4 | 4 | |
5 | | UsePrivateHeaders interface ; |
| 5 | UsePrivateHeaders interface storage ; |
6 | 6 | |
7 | 7 | SubDirSysHdrs $(SUBDIR) ; |
8 | 8 | SubDirHdrs [ FDirName $(SUBDIR) canna ] ; |