|
|
@ -6,7 +6,6 @@ import com.fr.design.extra.exe.callback.*; |
|
|
|
import com.fr.design.extra.exe.extratask.InstallPluginTask; |
|
|
|
import com.fr.design.extra.exe.extratask.InstallPluginTask; |
|
|
|
import com.fr.design.extra.exe.extratask.UpdatePluginTask; |
|
|
|
import com.fr.design.extra.exe.extratask.UpdatePluginTask; |
|
|
|
import com.fr.general.FRLogger; |
|
|
|
import com.fr.general.FRLogger; |
|
|
|
import com.fr.general.Inter; |
|
|
|
|
|
|
|
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.json.JSONObject; |
|
|
@ -14,12 +13,11 @@ import com.fr.plugin.context.PluginContext; |
|
|
|
import com.fr.plugin.context.PluginMarker; |
|
|
|
import com.fr.plugin.context.PluginMarker; |
|
|
|
import com.fr.plugin.manage.PluginManager; |
|
|
|
import com.fr.plugin.manage.PluginManager; |
|
|
|
import com.fr.plugin.manage.bbs.BBSPluginLogin; |
|
|
|
import com.fr.plugin.manage.bbs.BBSPluginLogin; |
|
|
|
|
|
|
|
import com.fr.plugin.manage.bbs.BBSUserInfo; |
|
|
|
import com.fr.plugin.manage.control.PluginTaskCallback; |
|
|
|
import com.fr.plugin.manage.control.PluginTaskCallback; |
|
|
|
import com.fr.plugin.view.PluginView; |
|
|
|
import com.fr.plugin.view.PluginView; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import org.json.JSONArray; |
|
|
|
import org.json.JSONArray; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
@ -51,13 +49,8 @@ public class PluginOperateUtils { |
|
|
|
if (BBSPluginLogin.getInstance().hasLogin()) { |
|
|
|
if (BBSPluginLogin.getInstance().hasLogin()) { |
|
|
|
for (int i = 0; i < pluginMarkerList.size(); i++) { |
|
|
|
for (int i = 0; i < pluginMarkerList.size(); i++) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
String latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarkerList.get(i).getPluginID()); |
|
|
|
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarkerList.get(i).getPluginID()); |
|
|
|
if (StringUtils.isEmpty(latestPluginInfo) || PluginConstants.CONNECTION_404.equals(latestPluginInfo)) { |
|
|
|
String latestPluginVersion = (String) latestPluginInfo.get("version"); |
|
|
|
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Connect_Failed"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JSONObject resultArr = new JSONObject(latestPluginInfo); |
|
|
|
|
|
|
|
String latestPluginVersion = (String) resultArr.get("version"); |
|
|
|
|
|
|
|
PluginMarker pluginMarker = pluginMarkerList.get(i); |
|
|
|
PluginMarker pluginMarker = pluginMarkerList.get(i); |
|
|
|
PluginMarker toPluginMarker = PluginMarker.create(pluginMarkerList.get(i).getPluginID(), latestPluginVersion); |
|
|
|
PluginMarker toPluginMarker = PluginMarker.create(pluginMarkerList.get(i).getPluginID(), latestPluginVersion); |
|
|
|
PluginManager.getController().download(pluginMarkerList.get(i), new DownloadCallback(new UpdatePluginTask(pluginMarker, toPluginMarker, jsCallback), jsCallback)); |
|
|
|
PluginManager.getController().download(pluginMarkerList.get(i), new DownloadCallback(new UpdatePluginTask(pluginMarker, toPluginMarker, jsCallback), jsCallback)); |
|
|
@ -90,6 +83,10 @@ public class PluginOperateUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void readUpdateOnline(JSCallback jsCallback) { |
|
|
|
public static void readUpdateOnline(JSCallback jsCallback) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new Thread(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
List<PluginView> plugins = PluginsReaderFromStore.readPluginsForUpdate(); |
|
|
|
List<PluginView> plugins = PluginsReaderFromStore.readPluginsForUpdate(); |
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
@ -103,14 +100,22 @@ public class PluginOperateUtils { |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void searchPlugin(String keyword, JSCallback jsCallback) { |
|
|
|
public static void searchPlugin(String keyword, JSCallback jsCallback) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
new Thread(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword); |
|
|
|
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword); |
|
|
|
String result = httpClient.getResponseText(); |
|
|
|
String result = httpClient.getResponseText(); |
|
|
|
jsCallback.execute(result); |
|
|
|
jsCallback.execute(result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).start(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
@ -150,6 +155,9 @@ public class PluginOperateUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void getPluginCategories(JSCallback jsCallback) { |
|
|
|
public static void getPluginCategories(JSCallback jsCallback) { |
|
|
|
|
|
|
|
new Thread(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
String result; |
|
|
|
String result; |
|
|
|
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); |
|
|
|
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); |
|
|
|
if (url != null) { |
|
|
|
if (url != null) { |
|
|
@ -160,9 +168,12 @@ public class PluginOperateUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
jsCallback.execute(result); |
|
|
|
jsCallback.execute(result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}).start(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void getLoginInfo(JSCallback jsCallback) { |
|
|
|
public static void getLoginInfo(JSCallback jsCallback) { |
|
|
|
String username = BBSPluginLogin.getInstance().getUserInfo().getUserName(); |
|
|
|
BBSUserInfo bbsUserInfo = BBSPluginLogin.getInstance().getUserInfo(); |
|
|
|
|
|
|
|
String username = bbsUserInfo == null ? "" : bbsUserInfo.getUserName(); |
|
|
|
String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName(); |
|
|
|
String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName(); |
|
|
|
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) { |
|
|
|
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|