1212import com .nbs .entity .PeerInfoBase ;
1313import com .nbs .ipfs .IPFSHelper ;
1414import com .nbs .ipfs .entity .IpfsMessage ;
15- import com .nbs .tools .ConfigHelper ;
1615import com .nbs .tools .PropertyUtil ;
1716import com .nbs .ui .frames .MainFrameOld ;
18- import UI .common .Base64CodecUtil ;
17+ import io .nbs .commons .utils .Base64CodecUtil ;
18+ import io .nbs .commons .helper .ConfigurationHelper ;
1919import io .nbs .commons .utils .BaseURLUtil ;
2020import io .nbs .commons .helper .RadomCharactersHelper ;
2121import io .ipfs .api .IPFS ;
2222import io .ipfs .api .JSONParser ;
23- import io .ipfs .api .MerkleNode ;
24- import io .ipfs .api .NamedStreamable ;
2523import io .ipfs .multihash .Multihash ;
2624import org .apache .commons .lang3 .StringUtils ;
2725import org .slf4j .Logger ;
@@ -112,6 +110,7 @@ public class AppMainWindow {
112110 * 联系人缓存
113111 */
114112 public static Map <String ,ContactsItem > peerItems = new HashMap <>();
113+ private ConfigurationHelper configurationHelper ;
115114
116115 public static void main (String [] args ){
117116 String basedir = System .getProperty ("app.home" );
@@ -143,7 +142,7 @@ public void run() {
143142 * @throws
144143 */
145144 public AppMainWindow (){
146-
145+ configurationHelper = ConfigurationHelper . getInstance ();
147146 initialize ();
148147 //订阅世界消息
149148 // subCtrlWorld();
@@ -166,7 +165,7 @@ private void loadWorldControllerListener(ImPeersService service){
166165 AtomicInteger size = new AtomicInteger (0 );
167166 new Thread (()->{
168167 logger .info ("Start up the World Controller Message........" );
169- IPFS worldIpfs = new IPFS (ConfigHelper .getInstance ().getIpfsAddress ());
168+ IPFS worldIpfs = new IPFS (ConfigurationHelper .getInstance ().getIPFSAddress ());
170169 while (true ){
171170 try {
172171 TimeUnit .MILLISECONDS .sleep (100 );
@@ -266,27 +265,27 @@ private void loadEnv(){
266265 logger .info (BaseURLUtil .getAppBaseDir ());
267266 logger .info (BaseURLUtil .getAppJarPath ());
268267 logger .info ("=====>>>>>>> NBS Chain Client4J ENV initializing......" );
269- Properties props = ConfigHelper .getInstance ().getEnv ();
268+ Properties props = ConfigurationHelper .getInstance ().getCfgProps ();
270269 for (String k : props .stringPropertyNames ()){
271270 String v = props .getProperty (k );
272271 logger .info (k +"=" +v );
273272 }
274273
275- /**
274+ /* */ /**
276275 * 初始化文件目录
277- */
278- File ipfsDir = new File (ConfigHelper . NBS_FILES_IPFS_ROOT );
276+ */ /*
277+ File ipfsDir = new File(AppGlobalCnst.consturactPath(AppGlobalCnst.NBS_ROOT) );
279278 if(ipfsDir.isDirectory()&& !ipfsDir.exists()){
280279 ipfsDir.mkdirs();
281280 }
282281
283- /**
282+ */ /**
284283 * 初始化
285- */
286- File f = new File (ConfigHelper . NBS_CACHE_AVATAR_ROOT_PATH );
284+ */ /*
285+ File f = new File(configurationHelper. );
287286 if(!f.exists()){
288287 f.mkdirs();
289- }
288+ }*/
290289
291290 /**
292291 * 构造id SELF
@@ -308,10 +307,10 @@ public void initAvatar(){
308307 try {
309308 String avatarHash ,suffix ,fileName ;
310309 Map cfgMap = ipfs .config .show ();
311- if (cfgMap .containsKey (ConfigHelper .JSON_AVATAR_KEY )&&cfgMap .containsKey (ConfigHelper .JSON_AVATAR_SUFFIX_KEY )){
310+ if (cfgMap .containsKey (ConfigurationHelper .JSON_AVATAR_KEY )&&cfgMap .containsKey (ConfigurationHelper .JSON_AVATAR_SUFFIX_KEY )){
312311 //
313312 }else {
314- File defaultAvatarImage = new File (ConfigHelper .PROFILE_ROOT + "defaults/nbs.png" );
313+ /* File defaultAvatarImage = new File(ConfigurationHelper .PROFILE_ROOT+ "defaults/nbs.png");
315314 if(!defaultAvatarImage.exists()||defaultAvatarImage.isDirectory())return;
316315 fileName = defaultAvatarImage.getName();
317316 suffix = fileName.substring(fileName.lastIndexOf("."));
@@ -330,6 +329,7 @@ public void initAvatar(){
330329 }
331330 SEFL_BASE.setAvatarHash(avatarHash);
332331 SEFL_BASE.setAvatarSuffix(suffix);
332+ */
333333 }
334334 } catch (IOException e ) {
335335 e .printStackTrace ();
@@ -402,7 +402,7 @@ private void safeAndFreshIM(ContactsItem item){
402402 @ Override
403403 public void run () {
404404 //TODO save sqlite
405- String headRootPath = ConfigHelper . NBS_CACHE_AVATAR_ROOT_PATH ;
405+ String headRootPath = ".nbs" ;
406406 try {
407407 if (StringUtils .isNotBlank (item .getAvatar ())){
408408 FileOutputStream fos ;
@@ -515,7 +515,7 @@ private static String _getNickName(){
515515 String tempNick = RadomCharactersHelper .getInstance ().generated ("NBSChain_" ,6 );
516516 try {
517517 Map cfgMap = ipfs .config .show ();
518- if (cfgMap .containsKey (ConfigHelper .JSON_NICKNAME_KEY )){
518+ /* if(cfgMap.containsKey(ConfigHelper.JSON_NICKNAME_KEY)){
519519 Object no = cfgMap.get(ConfigHelper.JSON_NICKNAME_KEY);
520520 if(no!=null&&no.toString().trim().length()<=0){
521521 Map res = ipfs.config.set(ConfigHelper.JSON_NICKNAME_KEY,tempNick);
@@ -526,7 +526,8 @@ private static String _getNickName(){
526526 }else {
527527 Map res = ipfs.config.set(ConfigHelper.JSON_NICKNAME_KEY,tempNick);
528528 return tempNick;
529- }
529+ }*/
530+ return null ;
530531 } catch (IOException e ) {
531532 logger .error ("GET NICKNAME ERROR :" ,e .getMessage ());
532533 return null ;
@@ -550,11 +551,11 @@ private static String getPeerId(){
550551 }
551552
552553
553- / **-------------------------------------------------*/
554- /**
554+ /* */ / **-------------------------------------------------*//*
555+ */ /**
555556 * 订阅世界主题
556557 * 控制
557- */
558+ */ /*
558559 private void subCtrlWorld(){
559560 new Thread(new Runnable() {
560561 @Override
@@ -568,5 +569,5 @@ public void run() {
568569 }
569570 }
570571 }).start();
571- }
572+ }*/
572573}
0 commit comments