Skip to content

Commit 38ab6da

Browse files
committed
update 2 3.3.0
1 parent 2be85d5 commit 38ab6da

27 files changed

+492
-149
lines changed

cn.ieclipse.smartqq.feature/feature.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<feature
33
id="cn.ieclipse.smartqq.feature"
44
label="SmartQQ"
5-
version="3.2.0.qualifier"
5+
version="3.3.0.qualifier"
66
provider-name="ieclipse.cn"
77
plugin="cn.ieclipse.smartqq">
88

cn.ieclipse.smartqq/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: SmartQQ
44
Bundle-SymbolicName: cn.ieclipse.smartqq;singleton:=true
5-
Bundle-Version: 3.2.0.qualifier
5+
Bundle-Version: 3.3.0.qualifier
66
Bundle-Activator: cn.ieclipse.smartim.IMPlugin
77
Bundle-Vendor: ieclipse.cn
88
Require-Bundle: org.eclipse.ui,
-2.88 KB
Binary file not shown.
57 Bytes
Binary file not shown.
99 Bytes
Binary file not shown.

cn.ieclipse.smartqq/src/cn/ieclipse/smartim/IMHistoryManager.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23-
import cn.ieclipse.smartim.helper.FileStorage;
23+
import cn.ieclipse.util.FileStorage;
2424
import cn.ieclipse.smartim.preferences.SettingsPerferencePage;
2525

2626
/**
@@ -37,15 +37,16 @@ public class IMHistoryManager {
3737
private long ts = System.currentTimeMillis();
3838

3939
private static IMHistoryManager instance = new IMHistoryManager();
40+
public static final String HISTORY_NAME = "history";
4041

4142
public static IMHistoryManager getInstance() {
4243
return instance;
4344
}
4445

45-
private FileStorage get(SmartClient client, String uin) {
46+
private FileStorage get(File dir, String uin) {
4647
FileStorage fs = stores.get(uin);
4748
if (fs == null) {
48-
File f = new File(client.getWorkDir("history"), uin);
49+
File f = new File(dir, uin);
4950
fs = new FileStorage(size, f.getAbsolutePath());
5051
boolean persistent = IMPlugin.getDefault().getPreferenceStore()
5152
.getBoolean(SettingsPerferencePage.LOG_HISTORY);
@@ -55,13 +56,13 @@ private FileStorage get(SmartClient client, String uin) {
5556
return fs;
5657
}
5758

58-
public List<String> load(SmartClient client, String uin) {
59-
FileStorage fs = get(client, uin);
59+
public List<String> load(File dir, String uin) {
60+
FileStorage fs = get(dir, uin);
6061
return fs.getLast(max);
6162
}
6263

63-
public boolean save(SmartClient client, String uin, String rawMsg) {
64-
FileStorage fs = get(client, uin);
64+
public boolean save(File dir, String uin, String rawMsg) {
65+
FileStorage fs = get(dir, uin);
6566
boolean ret = fs.append(rawMsg);
6667
ret = ret && fs.isPersistent();
6768
if (System.currentTimeMillis() - ts > 1000 * 120) {
@@ -71,8 +72,8 @@ public boolean save(SmartClient client, String uin, String rawMsg) {
7172
return ret;
7273
}
7374

74-
public boolean clear(SmartClient client, String uin) {
75-
FileStorage fs = get(client, uin);
75+
public boolean clear(File dir, String uin) {
76+
FileStorage fs = get(dir, uin);
7677
fs.release();
7778
return true;
7879
}

cn.ieclipse.smartqq/src/cn/ieclipse/smartim/IMReceiveCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ protected void handle(boolean unknown, boolean notify,
3030
SmartClient client = fContactView.getClient();
3131
String msg = getMsgContent(message, from);
3232
if (!unknown) {
33-
IMHistoryManager.getInstance().save(client,
34-
EncodeUtils.getMd5(contact.getName()), msg);
33+
String hf = EncodeUtils.getMd5(from.getContact().getName());
34+
IMHistoryManager.getInstance().save(client.getWorkDir(IMHistoryManager.HISTORY_NAME), hf, msg);
3535
}
3636

3737
if (notify) {

cn.ieclipse.smartqq/src/cn/ieclipse/smartim/actions/MockConsoleAction.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import cn.ieclipse.smartim.common.IMUtils;
2121
import cn.ieclipse.smartim.console.MockChatConsole;
2222
import cn.ieclipse.smartim.views.IMContactView;
23+
import cn.ieclipse.wechat.WXChatConsole;
24+
import cn.ieclipse.wechat.WXChatConsoleMock;
25+
import cn.ieclipse.wechat.WXContactView;
2326
import icons.SmartIcons;
2427

2528
/**
@@ -43,11 +46,14 @@ public void run() {
4346
Friend f = new Friend();
4447
f.setUserId(System.currentTimeMillis());
4548
f.setMarkname("Test" + System.currentTimeMillis());
46-
MockChatConsole console = new MockChatConsole(f, fContactView);
49+
MockChatConsole console = null;
50+
if (fContactView instanceof WXContactView) {
51+
console = new WXChatConsoleMock(f, fContactView);
52+
} else {
53+
console =new MockChatConsole(f, fContactView);
54+
}
55+
console.initMockMsg();
4756
fContactView.getTabbedChat().setSelection(console);
4857
fContactView.randBling();
49-
String msg = IMUtils.formatHtmlMsg(System.currentTimeMillis(), "明月",
50-
"我的未来不是梦http://www.baidu.com咕咕");
51-
console.write(msg);
5258
}
5359
}

cn.ieclipse.smartqq/src/cn/ieclipse/smartim/actions/SettingAction.java renamed to cn.ieclipse.smartqq/src/cn/ieclipse/smartim/actions/SettingsAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
* @date 2017年6月20日
3535
*
3636
*/
37-
public class SettingAction extends IMPanelAction {
38-
public SettingAction(IMContactView contactView) {
37+
public class SettingsAction extends IMPanelAction {
38+
public SettingsAction(IMContactView contactView) {
3939
super(contactView);
4040
setText("Settings");
4141
setToolTipText("Settings & Helps");

cn.ieclipse.smartqq/src/cn/ieclipse/smartim/common/IMUtils.java

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,21 @@ public static String formatMsg(long time, String name, CharSequence msg) {
8484
}
8585

8686
public static boolean isMySendMsg(String raw) {
87-
return raw.matches("^\\d{2}:\\d{2}:\\d{2} [.\\s\\S]*")
88-
|| raw.startsWith("<div");
87+
return raw.startsWith("<div")
88+
|| raw.matches("^\\d{2}:\\d{2}:\\d{2} [.\\s\\S]*");
8989
}
9090

9191
public static String formatHtmlMsg(String msg, boolean encodeHtml) {
9292
// TODO only replace the non-html tag space;
9393
String m = encodeHtml(msg);
9494
m = m.replaceAll("\r?\n", "<br/>");
95-
String content = encodeHtml ? autoLink(autoReviewLink(m)) : m;
95+
String content;
96+
if (encodeHtml) {
97+
content = autoLink(autoReviewLink(m).replace(" ", "&nbsp;"));
98+
}
99+
else {
100+
content = m.replace(" ", "&nbsp;");
101+
}
96102
return content;
97103
}
98104

@@ -114,7 +120,7 @@ public static String formatHtmlMsg(boolean my, boolean encodeHtml,
114120
return String.format(DIV_ROW_FORMAT, clz, t, name, name, content);
115121
}
116122

117-
private static String autoReviewLink(String input) {
123+
public static String autoReviewLink(String input) {
118124
Matcher m = Pattern.compile(CODE_REGEX, Pattern.MULTILINE)
119125
.matcher(input);
120126
if (m.find()) {
@@ -131,9 +137,9 @@ private static String autoReviewLink(String input) {
131137
return input;
132138
}
133139

134-
private static String autoLink(String input) {
135-
Pattern p = Patterns.WEB_URL; // Pattern.compile(LINK_REGEX,
136-
// Pattern.MULTILINE);
140+
public static String autoLink(String input) {
141+
Pattern p = Patterns.WEB_URL;// Pattern.compile(LINK_REGEX,
142+
// Pattern.MULTILINE);
137143
Matcher m = p.matcher(input);
138144

139145
List<String> groups = new ArrayList<>();
@@ -152,7 +158,23 @@ private static String autoLink(String input) {
152158
int e = ends.get(i);
153159
String g = groups.get(i);
154160
String http = null;
155-
if (!g.matches(Patterns.PROTOCOL)) {
161+
162+
String ucs = "";
163+
String rg = UCS_REGEX_BEGIN.matcher(g).replaceAll("$2");
164+
if (g.length() > rg.length()) {
165+
ucs = g.substring(0, g.length() - rg.length());
166+
g = rg;
167+
s = s + ucs.length();
168+
}
169+
170+
rg = UCS_REGEX_END.matcher(g).replaceAll("$1");
171+
if (g.length() > rg.length()) {
172+
ucs = g.substring(rg.length());
173+
g = rg;
174+
e = e - ucs.length();
175+
}
176+
177+
if (!PROTOCOL.matcher(g).find()) {
156178
boolean f = g.startsWith("www.") || g.endsWith(".com")
157179
|| g.endsWith(".cn");
158180
if (!f) {
@@ -176,26 +198,19 @@ else if (c == '>') {
176198
continue;
177199
}
178200
}
179-
String rg = UCS_REGEX.matcher(g).replaceAll("$1");
180-
String ucs = "";
181-
if (g.length() > rg.length()) {
182-
ucs = g.substring(rg.length());
183-
g = rg;
184-
e = e - ucs.length();
185-
}
186-
sb.delete(pos, offset + e);
201+
sb.delete(offset + s, offset + e);
187202
String link = http == null ? g : http + g;
188203
String ng = g;
189204
if (IMG_EXTS.indexOf(
190205
FileUtils.getExtension(g).toLowerCase()) >= 0) {
191206
ng = String.format(
192207
"<a href=\"%s\"><img src=\"%s\" alt=\"%s\" border=\"0\"/></a>",
193-
link, link, g);
208+
link, link, "无法预览,请尝试点击");
194209
}
195210
else {
196211
ng = String.format("<a href=\"%s\">%s</a>", link, g);
197212
}
198-
sb.insert(pos, ng);
213+
sb.insert(offset + s, ng);
199214
offset += ng.length() - g.length();
200215
}
201216
return sb.toString();
@@ -221,8 +236,11 @@ else if (c == '>') {
221236
+ "\uDAC0\uDC00-\uDAFF\uDFFD" + "\uDB00\uDC00-\uDB3F\uDFFD"
222237
+ "\uDB44\uDC00-\uDB7F\uDFFD"
223238
+ "&&[^\u00A0[\u2000-\u200A]\u2028\u2029\u202F\u3000]]";
224-
public static final Pattern UCS_REGEX = Pattern
239+
public static final Pattern UCS_REGEX_END = Pattern
225240
.compile("(.+?)(" + UCS_CHAR + "+$)");
241+
public static final Pattern UCS_REGEX_BEGIN = Pattern
242+
.compile("^(" + UCS_CHAR + "+)" + "(.+?)");
243+
public static final Pattern PROTOCOL = Pattern.compile(Patterns.PROTOCOL);
226244
public static final Pattern HTML_TAG_REGEX = Pattern
227245
.compile("<[^>]+>", Pattern.MULTILINE);
228246
}

cn.ieclipse.smartqq/src/cn/ieclipse/smartim/common/Notifications.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.eclipse.wb.swt.SWTResourceManager;
2222

2323
import cn.ieclipse.smartim.IMPlugin;
24-
import cn.ieclipse.smartim.actions.SettingAction;
24+
import cn.ieclipse.smartim.actions.SettingsAction;
2525
import cn.ieclipse.smartim.model.IContact;
2626
import cn.ieclipse.smartim.preferences.SettingsPerferencePage;
2727
import cn.ieclipse.smartim.views.IMContactView;
@@ -134,7 +134,7 @@ public void mouseDown(MouseEvent e) {
134134
fSettings.addSelectionListener(new SelectionAdapter() {
135135
@Override
136136
public void widgetSelected(SelectionEvent e) {
137-
SettingAction.open(SettingsPerferencePage.class.getName());
137+
SettingsAction.open(SettingsPerferencePage.class.getName());
138138
}
139139
});
140140

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Copyright 2014-2018 ieclipse.cn.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package cn.ieclipse.smartim.common;
17+
18+
import java.net.MalformedURLException;
19+
import java.net.URL;
20+
21+
import javax.swing.JOptionPane;
22+
import javax.swing.SwingUtilities;
23+
import javax.swing.text.html.StyleSheet;
24+
25+
import org.eclipse.core.runtime.Platform;
26+
27+
import com.google.gson.Gson;
28+
29+
import cn.ieclipse.smartim.IMPlugin;
30+
import okhttp3.Call;
31+
import okhttp3.OkHttpClient;
32+
import okhttp3.Request;
33+
import okhttp3.Response;
34+
35+
/**
36+
* 类/接口描述
37+
*
38+
* @author Jamling
39+
* @date 2019年1月16日
40+
*
41+
*/
42+
public class RestUtils {
43+
public final static String welcome_format = "http://api.ieclipse.cn/smartqq/index/welcome?p=%s&im=%s&v=%s";
44+
public final static String update_url = "http://api.ieclipse.cn/smartqq/index/notice?p=eclipse";
45+
public final static String about_url = "http://api.ieclipse.cn/smartqq/index/about";
46+
47+
48+
public static String getWelcome(String im) {
49+
try {
50+
okhttp3.Request.Builder builder = new okhttp3.Request.Builder()
51+
.url(String.format(welcome_format, "eclipse", im,
52+
Platform.getBundle(IMPlugin.PLUGIN_ID).getVersion().toString()))
53+
.get();
54+
Request request = builder.build();
55+
Call call = new OkHttpClient().newCall(request);
56+
Response response = call.execute();
57+
String json = response.body().string();
58+
if (response.code() == 200) {
59+
return json;
60+
}
61+
} catch (Exception e) {
62+
}
63+
return null;
64+
}
65+
66+
public static void checkUpdate() {
67+
new Thread() {
68+
public void run() {
69+
try {
70+
okhttp3.Request.Builder builder = (new okhttp3.Request.Builder())
71+
.url(RestUtils.update_url).get();
72+
Request request = builder.build();
73+
Call call = new OkHttpClient().newCall(request);
74+
Response response = call.execute();
75+
String json = response.body().string();
76+
if (response.code() == 200) {
77+
final UpdateInfo info = new Gson().fromJson(json,
78+
UpdateInfo.class);
79+
80+
}
81+
} catch (Exception ex) {
82+
}
83+
};
84+
}.start();
85+
}
86+
87+
public static class UpdateInfo {
88+
public String latest;
89+
public String desc;
90+
public String link;
91+
}
92+
93+
public static void loadStyleAsync(final StyleSheet styleSheet) {
94+
// new Thread() {
95+
// @Override
96+
// public void run() {
97+
// loadStyleSync(styleSheet);
98+
// }
99+
// }.start();
100+
}
101+
102+
public static void loadStyleSync(final StyleSheet styleSheet) {
103+
try {
104+
styleSheet.importStyleSheet(
105+
new URL("http://dl.ieclipse.cn/r/smartim.css"));
106+
} catch (MalformedURLException e1) {
107+
e1.printStackTrace();
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)