|
|
@ -6,20 +6,17 @@ import com.fr.design.dialog.UIDialog; |
|
|
|
import com.fr.design.extra.ucenter.Client; |
|
|
|
import com.fr.design.extra.ucenter.Client; |
|
|
|
import com.fr.design.extra.ucenter.XMLHelper; |
|
|
|
import com.fr.design.extra.ucenter.XMLHelper; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
|
|
|
import com.fr.general.SiteCenter; |
|
|
|
import com.fr.general.SiteCenter; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
|
|
|
import com.fr.stable.EncodeConstants; |
|
|
|
import com.fr.stable.EncodeConstants; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import javafx.scene.web.WebEngine; |
|
|
|
import javafx.scene.web.WebEngine; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
|
|
|
import java.net.URI; |
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
|
|
|
import java.net.URI; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.LinkedList; |
|
|
|
|
|
|
|
|
|
|
|
public class LoginWebBridge { |
|
|
|
public class LoginWebBridge { |
|
|
@ -47,50 +44,48 @@ public class LoginWebBridge { |
|
|
|
//用户名,密码为空
|
|
|
|
//用户名,密码为空
|
|
|
|
private static final String LOGIN_INFO_EMPTY = "-5"; |
|
|
|
private static final String LOGIN_INFO_EMPTY = "-5"; |
|
|
|
private static final int TIME_OUT = 10000; |
|
|
|
private static final int TIME_OUT = 10000; |
|
|
|
|
|
|
|
private static final String LOGIN_SUCCESS = "ok"; |
|
|
|
|
|
|
|
private static final String LOGIN_FAILED = "failed"; |
|
|
|
|
|
|
|
|
|
|
|
private static com.fr.design.extra.LoginWebBridge helper; |
|
|
|
private static LoginWebBridge helper; |
|
|
|
|
|
|
|
private UILabel pluginuiLabel; |
|
|
|
private UIDialog uiDialog; |
|
|
|
private UIDialog uiDialog; |
|
|
|
|
|
|
|
private UIDialog qqDialog; |
|
|
|
private UILabel uiLabel; |
|
|
|
private UILabel uiLabel; |
|
|
|
private String userName; |
|
|
|
private String userName; |
|
|
|
|
|
|
|
|
|
|
|
public int getMessageCount() { |
|
|
|
public LoginWebBridge() { |
|
|
|
return messageCount; |
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
} |
|
|
|
setUserName(username, uiLabel); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 测试论坛网络连接 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean testConnection() { |
|
|
|
|
|
|
|
HttpClient client = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.test")); |
|
|
|
|
|
|
|
return client.isServerAlive(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static com.fr.design.extra.LoginWebBridge getHelper() { |
|
|
|
public static LoginWebBridge getHelper() { |
|
|
|
if (helper != null) { |
|
|
|
if (helper != null) { |
|
|
|
return helper; |
|
|
|
return helper; |
|
|
|
} |
|
|
|
} |
|
|
|
synchronized (com.fr.design.extra.LoginWebBridge.class) { |
|
|
|
synchronized (LoginWebBridge.class) { |
|
|
|
if (helper == null) { |
|
|
|
if (helper == null) { |
|
|
|
helper = new com.fr.design.extra.LoginWebBridge(); |
|
|
|
helper = new LoginWebBridge(); |
|
|
|
} |
|
|
|
} |
|
|
|
return helper; |
|
|
|
return helper; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static com.fr.design.extra.LoginWebBridge getHelper(WebEngine webEngine) { |
|
|
|
public int getMessageCount() { |
|
|
|
getHelper(); |
|
|
|
return messageCount; |
|
|
|
helper.setEngine(webEngine); |
|
|
|
|
|
|
|
return helper; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private WebEngine webEngine; |
|
|
|
public void setUILabelInPlugin(UILabel uiLabel) { |
|
|
|
|
|
|
|
this.pluginuiLabel = uiLabel; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setEngine(WebEngine webEngine) { |
|
|
|
public void setQqDialog(UIDialog qqDialog) { |
|
|
|
this.webEngine = webEngine; |
|
|
|
closeQQWindow(); |
|
|
|
|
|
|
|
this.qqDialog = qqDialog; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setDialogHandle(UIDialog uiDialog) { |
|
|
|
public void setDialogHandle(UIDialog uiDialog) { |
|
|
|
|
|
|
|
closeWindow(); |
|
|
|
this.uiDialog = uiDialog; |
|
|
|
this.uiDialog = uiDialog; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -98,13 +93,9 @@ public class LoginWebBridge { |
|
|
|
this.uiLabel = uiLabel; |
|
|
|
this.uiLabel = uiLabel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public LoginWebBridge() { |
|
|
|
|
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
|
|
|
|
setUserName(username, uiLabel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置显示的用户名 |
|
|
|
* 设置显示的用户名 |
|
|
|
|
|
|
|
* |
|
|
|
* @param userName 登录用户名 |
|
|
|
* @param userName 登录用户名 |
|
|
|
* @param label label显示 |
|
|
|
* @param label label显示 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -118,8 +109,19 @@ public class LoginWebBridge { |
|
|
|
this.userName = userName; |
|
|
|
this.userName = userName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 测试论坛网络连接 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean testConnection() { |
|
|
|
|
|
|
|
HttpClient client = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.test")); |
|
|
|
|
|
|
|
return client.isServerAlive(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置获取的消息长度,并设置显示 |
|
|
|
* 设置获取的消息长度,并设置显示 |
|
|
|
|
|
|
|
* |
|
|
|
* @param count |
|
|
|
* @param count |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setMessageCount(int count) { |
|
|
|
public void setMessageCount(int count) { |
|
|
@ -177,6 +179,7 @@ public class LoginWebBridge { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设计器端的用户登录 |
|
|
|
* 设计器端的用户登录 |
|
|
|
|
|
|
|
* |
|
|
|
* @param username 用户名 |
|
|
|
* @param username 用户名 |
|
|
|
* @param password 密码 |
|
|
|
* @param password 密码 |
|
|
|
* @return 登录信息标志 |
|
|
|
* @return 登录信息标志 |
|
|
@ -187,6 +190,7 @@ public class LoginWebBridge { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 插件管理的用户登录部分 |
|
|
|
* 插件管理的用户登录部分 |
|
|
|
|
|
|
|
* |
|
|
|
* @param username 用户名 |
|
|
|
* @param username 用户名 |
|
|
|
* @param password 密码 |
|
|
|
* @param password 密码 |
|
|
|
* @param uiLabel 设计器端的label |
|
|
|
* @param uiLabel 设计器端的label |
|
|
@ -198,6 +202,7 @@ public class LoginWebBridge { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 登录操作 |
|
|
|
* 登录操作 |
|
|
|
|
|
|
|
* |
|
|
|
* @param username 用户名 |
|
|
|
* @param username 用户名 |
|
|
|
* @param password 密码 |
|
|
|
* @param password 密码 |
|
|
|
* @param uiLabel 两边的label显示 |
|
|
|
* @param uiLabel 两边的label显示 |
|
|
@ -231,8 +236,8 @@ public class LoginWebBridge { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 更新后台的用户信息 |
|
|
|
* 更新后台的用户信息 |
|
|
|
|
|
|
|
* |
|
|
|
* @param username 用户名 |
|
|
|
* @param username 用户名 |
|
|
|
* @param password 密码 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void updateUserInfo(String username) { |
|
|
|
public void updateUserInfo(String username) { |
|
|
|
this.userName = username; |
|
|
|
this.userName = username; |
|
|
@ -240,6 +245,7 @@ public class LoginWebBridge { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 关闭窗口并且重新赋值 |
|
|
|
* 关闭窗口并且重新赋值 |
|
|
|
|
|
|
|
* |
|
|
|
* @param username |
|
|
|
* @param username |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void loginSuccess(String username, UILabel uiLabel) { |
|
|
|
public void loginSuccess(String username, UILabel uiLabel) { |
|
|
@ -254,13 +260,7 @@ public class LoginWebBridge { |
|
|
|
SwingUtilities.invokeLater(new Runnable() { |
|
|
|
SwingUtilities.invokeLater(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
//弹出qq登录的窗口
|
|
|
|
WebViewDlgHelper.createQQLoginDialog(); |
|
|
|
QQLoginPane managerPane = new QQLoginPane(); |
|
|
|
|
|
|
|
UIDialog qqlog = new QQLoginDialog(DesignerContext.getDesignerFrame(),managerPane); |
|
|
|
|
|
|
|
QQLoginWebBridge.getHelper().setDialogHandle(uiDialog); |
|
|
|
|
|
|
|
QQLoginWebBridge.getHelper().setQQDialogHandle(qqlog); |
|
|
|
|
|
|
|
QQLoginWebBridge.getHelper().setUILabel(uiLabel); |
|
|
|
|
|
|
|
qqlog.setVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -294,4 +294,47 @@ public class LoginWebBridge { |
|
|
|
} |
|
|
|
} |
|
|
|
return UNKNOWN_ERROR; |
|
|
|
return UNKNOWN_ERROR; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 关闭QQ授权窗口 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void closeQQWindow() { |
|
|
|
|
|
|
|
if (qqDialog != null) { |
|
|
|
|
|
|
|
qqDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
|
|
|
|
|
|
|
qqDialog.setVisible(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取用户信息 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param userInfo |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void getLoginInfo(String userInfo) { |
|
|
|
|
|
|
|
org.json.JSONObject jo = new org.json.JSONObject(userInfo); |
|
|
|
|
|
|
|
String status = jo.get("status").toString(); |
|
|
|
|
|
|
|
if (status.equals(LOGIN_SUCCESS)) { |
|
|
|
|
|
|
|
String username = jo.get("username").toString(); |
|
|
|
|
|
|
|
int uid = Integer.parseInt(jo.get("uid") == null ? "" : jo.get("uid").toString()); |
|
|
|
|
|
|
|
closeWindow(); |
|
|
|
|
|
|
|
closeQQWindow(); |
|
|
|
|
|
|
|
pluginuiLabel.setText(username); |
|
|
|
|
|
|
|
DesignerEnvManager.getEnvManager().setBBSName(username); |
|
|
|
|
|
|
|
DesignerEnvManager.getEnvManager().setBbsUid(uid); |
|
|
|
|
|
|
|
DesignerEnvManager.getEnvManager().setInShowBBsName(username); |
|
|
|
|
|
|
|
} else if (status.equals(LOGIN_FAILED)) { |
|
|
|
|
|
|
|
//账号没有QQ授权
|
|
|
|
|
|
|
|
closeQQWindow(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("QQ_binding"))); |
|
|
|
|
|
|
|
} catch (Exception exp) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { |
|
|
|
|
|
|
|
if (url.indexOf("qqLogin.html") > 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |