Skip to content

Commit 463e00d

Browse files
committed
update 2 2.6.0
1 parent 7292d7b commit 463e00d

29 files changed

+848
-147
lines changed

lib/core-0.0.1.jar

-2.88 KB
Binary file not shown.

lib/smartqq-0.0.1.jar

57 Bytes
Binary file not shown.

lib/wechat-0.0.1.jar

99 Bytes
Binary file not shown.

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
]]></description>
1212

1313
<change-notes><![CDATA[
14+
v2.6.0 2019-02-26, 优化微信
1415
v2.4.0 2018-05-10, 修复部分微信用户登录异常的问题
1516
v2.3.2 2018-03-05, 优化链接自动识别,优化聊天记录
1617
v2.3.0 2018-02-27, 添加发送工程中的文件,图灵机器人,消息群发等功能<br/>

src/cn/ieclipse/smartim/IMHistoryManager.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@
1515
*/
1616
package cn.ieclipse.smartim;
1717

18-
import cn.ieclipse.smartim.helper.FileStorage;
19-
import cn.ieclipse.smartim.settings.SmartIMSettings;
20-
2118
import java.io.File;
2219
import java.util.HashMap;
2320
import java.util.List;
2421
import java.util.Map;
2522

23+
import cn.ieclipse.util.FileStorage;
24+
import cn.ieclipse.smartim.settings.SmartIMSettings;
25+
2626
/**
2727
* 类/接口描述
28-
*
28+
*
2929
* @author Jamling
3030
* @date 2017年10月23日
31-
*
3231
*/
3332
public class IMHistoryManager {
3433
private Map<String, FileStorage> stores = new HashMap<>();
@@ -37,30 +36,31 @@ public class IMHistoryManager {
3736
private long ts = System.currentTimeMillis();
3837

3938
private static IMHistoryManager instance = new IMHistoryManager();
40-
39+
public static final String HISTORY_NAME = "history";
40+
4141
public static IMHistoryManager getInstance() {
4242
return instance;
4343
}
44-
45-
private FileStorage get(SmartClient client, String uin) {
44+
45+
private FileStorage get(File dir, String uin) {
4646
FileStorage fs = stores.get(uin);
4747
if (fs == null) {
48-
File f = new File(client.getWorkDir("history"), uin);
48+
File f = new File(dir, uin);
4949
fs = new FileStorage(size, f.getAbsolutePath());
5050
boolean persistent = SmartIMSettings.getInstance().getState().LOG_HISTORY;
5151
fs.setPersistent(persistent);
5252
stores.put(uin, fs);
5353
}
5454
return fs;
5555
}
56-
57-
public List<String> load(SmartClient client, String uin) {
58-
FileStorage fs = get(client, uin);
56+
57+
public List<String> load(File dir, String uin) {
58+
FileStorage fs = get(dir, uin);
5959
return fs.getLast(max);
6060
}
61-
62-
public boolean save(SmartClient client, String uin, String rawMsg) {
63-
FileStorage fs = get(client, uin);
61+
62+
public boolean save(File dir, String uin, String rawMsg) {
63+
FileStorage fs = get(dir, uin);
6464
boolean ret = fs.append(rawMsg);
6565
ret = ret && fs.isPersistent();
6666
if (System.currentTimeMillis() - ts > 1000 * 120) {
@@ -70,8 +70,8 @@ public boolean save(SmartClient client, String uin, String rawMsg) {
7070
return ret;
7171
}
7272

73-
public boolean clear(SmartClient client, String uin) {
74-
FileStorage fs = get(client, uin);
73+
public boolean clear(File dir, String uin) {
74+
FileStorage fs = get(dir, uin);
7575
fs.release();
7676
return true;
7777
}

src/cn/ieclipse/smartim/IMReceiveCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected void handle(boolean unknown, boolean notify,
3232
String msg = getMsgContent(message, from);
3333
if (!unknown) {
3434
String hf = EncodeUtils.getMd5(from.getContact().getName());
35-
IMHistoryManager.getInstance().save(client, hf, msg);
35+
IMHistoryManager.getInstance().save(client.getWorkDir(IMHistoryManager.HISTORY_NAME), hf, msg);
3636
}
3737

3838
if (notify) {

src/cn/ieclipse/smartim/IMWindowFactory.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,22 @@ public void stateChanged() {
6464
}
6565

6666
private void createContents(@NotNull Project project, @NotNull ToolWindow toolWindow) {
67-
SmartQQPanel qqPanel = new SmartQQPanel(project, toolWindow);
67+
File dir = new File(getWorkDir(), "SmartIM");
68+
if (dir.exists()) {
69+
dir.mkdirs();
70+
}
71+
System.setProperty("log.home", dir.getAbsolutePath());
6872
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
69-
Content content = contentFactory.createContent(qqPanel, "SmartQQ", false);
70-
toolWindow.getContentManager().addContent(content, 0);
73+
Content content = null;
7174

7275
WechatPanel wechatPanel = new WechatPanel(project, toolWindow);
7376
content = contentFactory.createContent(wechatPanel, "Wechat", false);
77+
toolWindow.getContentManager().addContent(content, 0);
78+
79+
SmartQQPanel qqPanel = new SmartQQPanel(project, toolWindow);
80+
content = contentFactory.createContent(qqPanel, "SmartQQ", false);
7481
toolWindow.getContentManager().addContent(content, 1);
82+
7583
}
7684

7785
private Content createContentPanel(Project project, ToolWindow toolWindow) {

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import cn.ieclipse.smartim.console.MockChatConsole;
44
import cn.ieclipse.smartim.model.impl.AbstractContact;
55
import cn.ieclipse.smartim.views.IMPanel;
6+
import cn.ieclipse.wechat.WXChatConsoleMock;
7+
import cn.ieclipse.wechat.WechatPanel;
68
import com.intellij.openapi.actionSystem.AnActionEvent;
79
import icons.SmartIcons;
810

@@ -29,8 +31,16 @@ public String getUin() {
2931
}
3032
};
3133

32-
MockChatConsole console = new MockChatConsole(contact, imPanel);
34+
MockChatConsole console = null;
35+
if (imPanel instanceof WechatPanel) {
36+
console = new WXChatConsoleMock(contact, imPanel);
37+
}
38+
else {
39+
console = new MockChatConsole(contact, imPanel);
40+
}
3341
console.setName(contact.getName());
3442
imPanel.addConsole(console);
43+
imPanel.randBling();
44+
console.initMockMsg();
3545
}
3646
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
/**
1010
* Created by Jamling on 2017/7/11.
1111
*/
12-
public class SettingAction extends IMPanelAction {
13-
public SettingAction(IMPanel panel) {
12+
public class SettingsAction extends IMPanelAction {
13+
public SettingsAction(IMPanel panel) {
1414
super(panel, "设置", "首选项及设置", SmartIcons.settings);
1515
this.imPanel = panel;
1616
}

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

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public static String formatMsg(long time, String name, CharSequence msg) {
8080
}
8181

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

8787
public static String formatHtmlMsg(String msg, boolean encodeHtml) {
@@ -116,7 +116,7 @@ public static String formatHtmlMsg(boolean my, boolean encodeHtml,
116116
return String.format(DIV_ROW_FORMAT, clz, t, name, name, content);
117117
}
118118

119-
private static String autoReviewLink(String input) {
119+
public static String autoReviewLink(String input) {
120120
Matcher m = Pattern.compile(CODE_REGEX, Pattern.MULTILINE)
121121
.matcher(input);
122122
if (m.find()) {
@@ -133,7 +133,7 @@ private static String autoReviewLink(String input) {
133133
return input;
134134
}
135135

136-
private static String autoLink(String input) {
136+
public static String autoLink(String input) {
137137
Pattern p = Patterns.WEB_URL;// Pattern.compile(LINK_REGEX, Pattern.MULTILINE);
138138
Matcher m = p.matcher(input);
139139

@@ -153,7 +153,23 @@ private static String autoLink(String input) {
153153
int e = ends.get(i);
154154
String g = groups.get(i);
155155
String http = null;
156-
if (!g.matches(Patterns.PROTOCOL)) {
156+
157+
String ucs = "";
158+
String rg = UCS_REGEX_BEGIN.matcher(g).replaceAll("$2");
159+
if (g.length() > rg.length()) {
160+
ucs = g.substring(0, g.length() - rg.length());
161+
g = rg;
162+
s = s + ucs.length();
163+
}
164+
165+
rg = UCS_REGEX_END.matcher(g).replaceAll("$1");
166+
if (g.length() > rg.length()) {
167+
ucs = g.substring(rg.length());
168+
g = rg;
169+
e = e - ucs.length();
170+
}
171+
172+
if (!PROTOCOL.matcher(g).find()) {
157173
boolean f = g.startsWith("www.") || g.endsWith(".com")
158174
|| g.endsWith(".cn");
159175
if (!f) {
@@ -176,14 +192,19 @@ private static String autoLink(String input) {
176192
continue;
177193
}
178194
}
179-
sb.delete(pos, offset + e);
195+
sb.delete(offset + s, offset + e);
196+
String link = http == null ? g : http + g;
180197
String ng = g;
181-
if (IMG_EXTS.indexOf(FileUtils.getExtension(g).toLowerCase()) >= 0) {
182-
ng = String.format("<a href=\"%s\"><img src=\"%s\" alt=\"%s\" border=\"0\"/></a>", g, g, g);
183-
} else {
184-
ng = String.format("<a href=\"%s\">%s</a>", g, g);
198+
if (IMG_EXTS.indexOf(
199+
FileUtils.getExtension(g).toLowerCase()) >= 0) {
200+
ng = String.format(
201+
"<a href=\"%s\"><img src=\"%s\" alt=\"%s\" border=\"0\"/></a>",
202+
link, link, "无法预览,请尝试点击");
203+
}
204+
else {
205+
ng = String.format("<a href=\"%s\">%s</a>", link, g);
185206
}
186-
sb.insert(pos, ng);
207+
sb.insert(offset + s, ng);
187208
offset += ng.length() - g.length();
188209
}
189210
return sb.toString();
@@ -198,4 +219,19 @@ private static String autoLink(String input) {
198219
public static final List<String> IMG_EXTS = Arrays.asList("png", "jpg", "gif", "webp");
199220
public static final String CODE_REGEX = "Code: [\\S ]+:[\\d]+ ?";
200221
public static final String LINK_REGEX = "(https?|ftp|file)://(([\\w-~]+).)+([\\w-~\\/])+(((?!\\.)(\\S))+(\\.\\w+(\\?(\\w+=\\S&?)*)?)?)?";
222+
public static final String UCS_CHAR = "[" + "\u00A0-\uD7FF"
223+
+ "\uF900-\uFDCF" + "\uFDF0-\uFFEF" + "\uD800\uDC00-\uD83F\uDFFD"
224+
+ "\uD840\uDC00-\uD87F\uDFFD" + "\uD880\uDC00-\uD8BF\uDFFD"
225+
+ "\uD8C0\uDC00-\uD8FF\uDFFD" + "\uD900\uDC00-\uD93F\uDFFD"
226+
+ "\uD940\uDC00-\uD97F\uDFFD" + "\uD980\uDC00-\uD9BF\uDFFD"
227+
+ "\uD9C0\uDC00-\uD9FF\uDFFD" + "\uDA00\uDC00-\uDA3F\uDFFD"
228+
+ "\uDA40\uDC00-\uDA7F\uDFFD" + "\uDA80\uDC00-\uDABF\uDFFD"
229+
+ "\uDAC0\uDC00-\uDAFF\uDFFD" + "\uDB00\uDC00-\uDB3F\uDFFD"
230+
+ "\uDB44\uDC00-\uDB7F\uDFFD"
231+
+ "&&[^\u00A0[\u2000-\u200A]\u2028\u2029\u202F\u3000]]";
232+
public static final Pattern UCS_REGEX_END = Pattern
233+
.compile("(.+?)(" + UCS_CHAR + "+$)");
234+
public static final Pattern UCS_REGEX_BEGIN = Pattern
235+
.compile("^(" + UCS_CHAR + "+)" + "(.+?)");
236+
public static final Pattern PROTOCOL = Pattern.compile(Patterns.PROTOCOL);
201237
}

0 commit comments

Comments
 (0)