Skip to content

Commit

Permalink
add lost feature to eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamling committed Feb 27, 2018
1 parent a749ff4 commit da7c152
Show file tree
Hide file tree
Showing 68 changed files with 2,361 additions and 528 deletions.
Binary file modified lib/core-0.0.1.jar
Binary file not shown.
Binary file modified lib/smartqq-0.0.1.jar
Binary file not shown.
Binary file modified lib/wechat-0.0.1.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
factoryClass="cn.ieclipse.smartim.IMWindowFactory"
icon="/icons/im.png">
</toolWindow>
<applicationConfigurable instance="cn.ieclipse.smartim.settings.SmartSettingsPanel"/>
<applicationConfigurable instance="cn.ieclipse.smartim.settings.GeneralPanel"/>
<applicationService serviceImplementation="cn.ieclipse.smartim.settings.SmartIMSettings"/>
</extensions>
<actions>
Expand Down
Binary file added resources/icons/broadcast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/clear_co.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions src/cn/ieclipse/smartim/IMClientFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
*/
package cn.ieclipse.smartim;

import com.scienjus.smartqq.client.SmartQQClient;
import io.github.biezhi.wechat.api.WechatClient;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import com.scienjus.smartqq.client.SmartQQClient;

import io.github.biezhi.wechat.api.WechatClient;

/**
* 类/接口描述
*
Expand Down
13 changes: 11 additions & 2 deletions src/cn/ieclipse/smartim/IMHistoryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
*/
package cn.ieclipse.smartim;

import cn.ieclipse.smartim.helper.FileStorage;
import cn.ieclipse.smartim.settings.SmartIMSettings;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.ieclipse.smartim.helper.FileStorage;

/**
* 类/接口描述
*
Expand All @@ -45,6 +46,8 @@ private FileStorage get(SmartClient client, String uin) {
if (fs == null) {
File f = new File(client.getWorkDir("history"), uin);
fs = new FileStorage(size, f.getAbsolutePath());
boolean persistent = SmartIMSettings.getInstance().getState().LOG_HISTORY;
fs.setPersistent(persistent);
stores.put(uin, fs);
}
return fs;
Expand All @@ -61,4 +64,10 @@ public boolean save(SmartClient client, String uin, String rawMsg) {
ret = ret && fs.isPersistent() && fs.flush();
return ret;
}

public boolean clear(SmartClient client, String uin) {
FileStorage fs = get(client, uin);
fs.release();
return true;
}
}
3 changes: 2 additions & 1 deletion src/cn/ieclipse/smartim/IMReceiveCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cn.ieclipse.smartim.model.impl.AbstractMessage;
import cn.ieclipse.smartim.settings.SmartIMSettings;
import cn.ieclipse.smartim.views.IMPanel;
import cn.ieclipse.util.EncodeUtils;

public abstract class IMReceiveCallback implements ReceiveCallback {
protected IMChatConsole lastConsole;
Expand All @@ -31,7 +32,7 @@ protected void handle(boolean unknown, boolean notify,
String msg = getMsgContent(message, from);
if (!unknown) {
IMHistoryManager.getInstance().save(client,
from.getContact().getUin(), msg);
EncodeUtils.getMd5(contact.getName()), msg);
}

if (notify) {
Expand Down
37 changes: 30 additions & 7 deletions src/cn/ieclipse/smartim/IMRobotCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,48 @@
*/
package cn.ieclipse.smartim;

import cn.ieclipse.smartim.callback.ModificationCallback;
import cn.ieclipse.smartim.callback.ReceiveCallback;
import cn.ieclipse.smartim.robot.TuringRobot;
import cn.ieclipse.smartim.settings.SmartIMSettings;
import cn.ieclipse.util.EncodeUtils;

/**
* 类/接口描述
*
*
* @author Jamling
* @date 2017年10月16日
*
*
*/
public abstract class IMRobotCallback implements ReceiveCallback {
public abstract class IMRobotCallback
implements ReceiveCallback, ModificationCallback {
public static final String SEP = " ";
protected TuringRobot turingRobot;
protected TuringRobot turingRobot = new TuringRobot("Turing", 0, null);

public static boolean isEnable() {
return false;
return SmartIMSettings.getInstance().getState().ROBOT_ENABLE;
}

public static String getRobotName() {
return SmartIMSettings.getInstance().getState().ROBOT_NAME;
}

/**
* 对userId或groupId进行加密
*
* @param id
* userId
* @return 加密后的md5字串
*/
public static String encodeUid(String id) {
return EncodeUtils.getMd5(id);
}

public static String getTuringApiKey() {
String key = SmartIMSettings.getInstance().getState().ROBOT_KEY;
if (key != null && !key.isEmpty()) {
return key;
}
return null;
}
}
6 changes: 1 addition & 5 deletions src/cn/ieclipse/smartim/IMSendCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public void onSendResult(int type, String targetId, CharSequence msg,
}

protected void onSuccess(int type, String targetId, CharSequence msg) {
// SmartClient client = getIMPanel().getClient();
// String name = client.getAccount().getName();
// IMHistoryManager.getInstance().save(client, targetId,
// IMUtils.formatHtmlMyMsg(System.currentTimeMillis(), name, msg));
imPanel.notifyUpdateContacts(0, true);
}

Expand All @@ -61,7 +57,6 @@ protected void onFailure(int type, String targetId, CharSequence msg,
String s = IMUtils.isEmpty(msg) ? ""
: (msg.length() > 20 ? msg.toString().substring(0, 20) + "..."
: msg.toString());
IMChatConsole console = getIMPanel().findConsoleById(targetId, true);
String code = "";
if (t != null) {
if (t instanceof LogicException) {
Expand All @@ -72,6 +67,7 @@ protected void onFailure(int type, String targetId, CharSequence msg,
((HttpException) t).getCode());
}
}
IMChatConsole console = getIMPanel().findConsoleById(targetId, true);
if (console != null) {
console.error(String.format("%s 发送失败!%s", msg, code));
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/cn/ieclipse/smartim/IMWindowFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import cn.ieclipse.smartqq.SmartQQPanel;
import cn.ieclipse.wechat.WechatPanel;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ToolWindowManager;
Expand Down
25 changes: 0 additions & 25 deletions src/cn/ieclipse/smartim/actions/AbstractAction.java

This file was deleted.

36 changes: 36 additions & 0 deletions src/cn/ieclipse/smartim/actions/BroadcastAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cn.ieclipse.smartim.actions;

import cn.ieclipse.smartim.SmartClient;
import cn.ieclipse.smartim.views.IMPanel;
import com.intellij.openapi.actionSystem.AnActionEvent;
import icons.SmartIcons;

import javax.swing.*;

/**
* Created by Jamling on 2018/02/23.
*/
public class BroadcastAction extends IMPanelAction {

public BroadcastAction(IMPanel panel) {
super(panel, "群发", "消息群发", SmartIcons.broadcast);
}

@Override
public void actionPerformed(AnActionEvent anActionEvent) {
final SmartClient client = imPanel.getClient();
if (client.isLogin()) {
openDialog();
}
else {
JOptionPane.showInternalMessageDialog(null, "已断开连接,请重新登录成功后再试");
}
}

protected void openDialog() {

}

public static String groupMacro = "{group}";
public static String memberMacro = "{member}";
}
40 changes: 40 additions & 0 deletions src/cn/ieclipse/smartim/actions/ClearHistoryAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2014-2018 ieclipse.cn.
*
* 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.
*/
package cn.ieclipse.smartim.actions;

import cn.ieclipse.smartim.console.IMChatConsole;
import com.intellij.openapi.actionSystem.AnActionEvent;
import icons.SmartIcons;

/**
* 类/接口描述
*
* @author Jamling
* @date 2018年2月24日
*/
public class ClearHistoryAction extends IMChatAction {

public ClearHistoryAction(IMChatConsole console) {
super(console, "", "Clear history", SmartIcons.clear);
}

@Override
public void actionPerformed(AnActionEvent anActionEvent) {
if (console != null) {
console.clearHistories();
}
}
}
4 changes: 2 additions & 2 deletions src/cn/ieclipse/smartim/actions/DisconnectAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
/**
* Created by Jamling on 2017/11/1.
*/
public class DisconnectAction extends AbstractAction {
public class DisconnectAction extends IMPanelAction {
public DisconnectAction(IMPanel panel) {
super("Close", "Close the connection", SmartIcons.close, panel);
super(panel, "Close", "Close the connection", SmartIcons.close);
}

@Override
Expand Down
40 changes: 40 additions & 0 deletions src/cn/ieclipse/smartim/actions/IMChatAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2014-2017 ieclipse.cn.
*
* 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.
*/
package cn.ieclipse.smartim.actions;

import cn.ieclipse.smartim.console.IMChatConsole;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
* Created by Jamling on 2017/7/12.
*/
public class IMChatAction extends DumbAwareAction {
protected IMChatConsole console;

public IMChatAction(IMChatConsole console, @Nullable String text, @Nullable String description, @Nullable Icon icon) {
super(text, description, icon);
this.console = console;
}

@Override
public void actionPerformed(AnActionEvent anActionEvent) {

}
}
40 changes: 40 additions & 0 deletions src/cn/ieclipse/smartim/actions/IMPanelAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2014-2017 ieclipse.cn.
*
* 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.
*/
package cn.ieclipse.smartim.actions;

import cn.ieclipse.smartim.views.IMPanel;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
* Created by Jamling on 2017/7/12.
*/
public class IMPanelAction extends DumbAwareAction {
protected IMPanel imPanel;

public IMPanelAction(IMPanel panel, @Nullable String text, @Nullable String description, @Nullable Icon icon) {
super(text, description, icon);
this.imPanel = panel;
}

@Override
public void actionPerformed(AnActionEvent anActionEvent) {

}
}
Loading

0 comments on commit da7c152

Please sign in to comment.