(boolean fromResource)
| 86 | } |
| 87 | |
| 88 | public final void importData(boolean fromResource) { |
| 89 | String accounts = ""; |
| 90 | |
| 91 | if (!fromResource) { |
| 92 | FileIO fileIO = FileIO.createConnection(file); |
| 93 | accounts = fileIO.fileReadUtf(); |
| 94 | } else { |
| 95 | byte[] bodyMessage = new byte[4096]; |
| 96 | try { |
| 97 | InputStream in = StaticData.getInstance().getAssetsLoader().getResourceAsStream("/def_accounts.txt"); |
| 98 | if (in != null) { |
| 99 | in.read(bodyMessage); |
| 100 | } |
| 101 | } catch (IOException ex) { |
| 102 | if (StaticData.Debug) { |
| 103 | ex.printStackTrace(); |
| 104 | } |
| 105 | } |
| 106 | if (bodyMessage != null) { |
| 107 | accounts = new String(bodyMessage, 0, bodyMessage.length); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | if (accounts != null) { |
| 112 | try { |
| 113 | int pos = 0; |
| 114 | int start_pos = 0; |
| 115 | int end_pos = 0; |
| 116 | |
| 117 | boolean parse = true; |
| 118 | |
| 119 | while (parse) { |
| 120 | start_pos = accounts.indexOf("<a>", pos); |
| 121 | end_pos = accounts.indexOf("</a>", pos); |
| 122 | |
| 123 | if (start_pos > -1 && end_pos > -1) { |
| 124 | pos = end_pos + 4; |
| 125 | String tempstr = accounts.substring(start_pos + 3, end_pos); |
| 126 | |
| 127 | Account account = new Account(); |
| 128 | account.JID = new Jid(findBlock(tempstr, userName), |
| 129 | findBlock(tempstr, server), |
| 130 | findBlock(tempstr, resource)); |
| 131 | account.password = findBlock(tempstr, password); |
| 132 | account.hostAddr = findBlock(tempstr, hostAddr); |
| 133 | account.port = Integer.parseInt(findBlock(tempstr, port)); |
| 134 | account.nick = findBlock(tempstr, nick); |
| 135 | account.plainAuth = (findBlock(tempstr, plainAuth).equals("1")) ? true : false; |
| 136 | account.mucOnly = (findBlock(tempstr, mucOnly).equals("1")) ? true : false; |
| 137 | //#if HTTPPOLL || HTTPCONNECT || HTTPBIND |
| 138 | //# account.setEnableProxy(findBlock(tempstr, enableProxy).equals("1") ? true : false); |
| 139 | //# account.proxyHostAddr = findBlock(tempstr, proxyHostAddr); |
| 140 | //# account.setProxyPort(Integer.parseInt(findBlock(tempstr, proxyPort))); |
| 141 | //#endif |
| 142 | account.setUseCompression((findBlock(tempstr, compression).equals("1")) ? true : false); |
| 143 | account.keepAlivePeriod = Integer.parseInt(findBlock(tempstr, keepAlivePeriod)); |
| 144 | //#ifdef HTTPCONNECT |
| 145 | //# account.setProxyUser(findBlock(tempstr, proxyUser)); |
no test coverage detected