Changeset 19
- Timestamp:
- 07/03/07 19:26:57 (5 years ago)
- Location:
- mymrc/trunk/Java-client/src/org/myMRC
- Files:
-
- 6 modified
-
control/Controller.java (modified) (8 diffs)
-
events/Content.java (modified) (5 diffs)
-
events/Opcode.java (modified) (1 diff)
-
net/CommunicationController.java (modified) (3 diffs)
-
parser/FormParser.java (modified) (3 diffs)
-
screen/FormScreen.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mymrc/trunk/Java-client/src/org/myMRC/control/Controller.java
r15 r19 179 179 */ 180 180 public void processInternalEvent(int opcode, String data) { 181 AlertScreen alert = null; 181 AlertScreen alert = new AlertScreen(null, opcode, display.getCurrent()); 182 182 183 switch (opcode) { 183 case 900:184 case Opcode.IOP_START: 184 185 if (!communicator.isAlive()) { 185 186 this.handle(Opcode.IOP_PARSEFORM, Content.CONT_START); … … 189 190 break; 190 191 191 case 990:192 case Opcode.IOP_CONNECT: 192 193 // connect 193 194 /* 194 * FIXME: without using a Thread here, the connection opening 195 * blocks and nothing happens - with a Thread it somehow 196 * magically works.. 197 */ 198 /* 199 try { 200 System.out.println("trying to connect to " + config.getServerString()); 201 communicator.open("socket://" + config.getServerString()); 202 } catch (IOException ioe) { 203 ioe.printStackTrace(); 204 } 195 * We have to use a separate thread to start the 196 * CommunicationController. 205 197 */ 206 198 if (!communicator.isAlive()) { … … 213 205 break; 214 206 215 case Opcode.IOP_DISCONNECT: /* 991 */ 207 case Opcode.IOP_DISCONNECT_CONF: 208 // disconnect confirmation 209 //alert.setTitle("Disconnect?"); 210 alert.setString("Do you really want to disconnect?"); 211 display.setCurrent(alert); 212 break; 213 214 case Opcode.IOP_DISCONNECT_FORCED: 215 alert.setString("Network communication error: " + data); 216 display.setCurrent(alert); 217 break; 218 219 case Opcode.IOP_DISCONNECT: 216 220 // disconnect 217 221 System.out.println("handling IOP_DISCONNECT"); … … 220 224 break; 221 225 222 case 901:226 case Opcode.IOP_ABOUT_DIALOG: 223 227 // about 224 228 System.out.println("processing internal event \"About\""); … … 226 230 break; 227 231 228 case 920:232 case Opcode.IOP_SETTINGS: 229 233 // settings 230 234 this.handle(Opcode.IOP_PARSEFORM, Content.CONT_SETTINGS); 231 235 break; 232 236 233 case 921:237 case Opcode.IOP_SETTINGS_SAVE: 234 238 // save settings 235 239 config.writeSettings(form); … … 238 242 } catch (IOException ioe) { 239 243 ioe.printStackTrace(); 240 alert = new AlertScreen("Saving settings failed!", 921, null);244 //alert.setTitle("Saving settings failed!"); 241 245 alert.setTimeout(alert.FOREVER); 242 246 alert.setString("Error while saving settings:\n" + ioe.getMessage()); 243 247 display.setCurrent(alert); 244 break; /* uhm.. I don't get it, I really NEED a break here.. 245 * well, at least in a test case where I manually 246 * threw an IOException .. should be checked when 247 * we have some real exception case 248 */ 248 break; 249 249 } 250 alert = new AlertScreen("Settings saved", 921, null);250 //alert.setTitle("Settings saved"); 251 251 alert.setString("Your settings have been saved successfully"); 252 252 display.setCurrent(alert); … … 254 254 break; 255 255 256 case 998: // exit confirmation257 alert = new AlertScreen("Exit?", 998, display.getCurrent());256 case Opcode.IOP_INT_EXIT_CONF: // exit confirmation 257 //alert.setTitle("Exit?"); 258 258 alert.setString("Do you really want to quit?"); 259 259 display.setCurrent(alert); 260 260 break; 261 261 262 case 999:262 case Opcode.IOP_INT_EXIT: 263 263 // exit (the real one) 264 264 if (communicator.isAlive()) { … … 294 294 alert.setString("Unable to connect to remote server:\n" + e.getMessage()); 295 295 display.setCurrent(alert); 296 return; /* hum.. */296 return; 297 297 } 298 298 CommunicationController.getInstance().send(Opcode.OP_HELLO, null); -
mymrc/trunk/Java-client/src/org/myMRC/events/Content.java
r15 r19 26 26 " <string label=\"hallo :)\"/>" + 27 27 " <string label=\"Not Connected\"/>" + 28 " <command label=\"Connect\" opcode=\"0 990\"/>" +29 " <command label=\"Settings\" opcode=\"0 920\"/>" +30 " <command label=\"About\" opcode=\"0 901\"/>" +31 " <command label=\"Exit\" opcode=\"0 998\"/>" +32 " <command type=\"back\" label=\"Exit\" opcode=\"0 998\"/>" +28 " <command label=\"Connect\" opcode=\"0" + Opcode.IOP_CONNECT + "\"/>" + 29 " <command label=\"Settings\" opcode=\"0" + Opcode.IOP_SETTINGS + "\"/>" + 30 " <command label=\"About\" opcode=\"0" + Opcode.IOP_ABOUT_DIALOG + "\"/>" + 31 " <command label=\"Exit\" opcode=\"0" + Opcode.IOP_INT_EXIT_CONF + "\"/>" + 32 " <command type=\"back\" label=\"Exit\" opcode=\"0" + Opcode.IOP_INT_EXIT_CONF + "\"/>" + 33 33 "</form>"; 34 34 … … 38 38 " <string label=\"hallo :)\"/>" + 39 39 " <string label=\"Connection lost!\"/>" + 40 " <command label=\"Connect\" opcode=\"0 990\"/>" +41 " <command label=\"Settings\" opcode=\"0 920\"/>" +42 " <command label=\"About\" opcode=\"0 901\"/>" +43 " <command label=\"Exit\" opcode=\"0 998\"/>" +44 " <command type=\"back\" label=\"Exit\" opcode=\"0 998\"/>" +40 " <command label=\"Connect\" opcode=\"0" + Opcode.IOP_CONNECT + "\"/>" + 41 " <command label=\"Settings\" opcode=\"0" + Opcode.IOP_SETTINGS + "\"/>" + 42 " <command label=\"About\" opcode=\"0" + Opcode.IOP_ABOUT_DIALOG + "\"/>" + 43 " <command label=\"Exit\" opcode=\"0" + Opcode.IOP_INT_EXIT_CONF + "\"/>" + 44 " <command type=\"back\" label=\"Exit\" opcode=\"0" + Opcode.IOP_INT_EXIT_CONF + "\"/>" + 45 45 "</form>"; 46 46 … … 49 49 //" <image file=\"mymrc.png\"/>" + 50 50 " <string label=\"hallo :)\"/>" + 51 " <string label=\"OH OH! this is deprecated, it shouldn't be displayed\"/>" + 51 52 " <command label=\"Continue\" opcode=\"0000\"/>" + 52 53 " <command label=\"Disconnect\" opcode=\"0991\"/>" + … … 61 62 " <textfield setting=\"serverHost\" label=\"Server Host\" size=\"20\"/>" + 62 63 " <textfield setting=\"serverPort\" label=\"Server Port\" type=\"number\" size=\"5\"/>" + 63 " <command type=\"back\" label=\"Cancel\" opcode=\"0 900\"/>" +64 " <command label=\"Save\" opcode=\"0 921\"/>" +64 " <command type=\"back\" label=\"Cancel\" opcode=\"0" + Opcode.IOP_START + "\"/>" + 65 " <command label=\"Save\" opcode=\"0" + Opcode.IOP_SETTINGS_SAVE + "\"/>" + 65 66 "</form>"; 66 67 … … 69 70 " <string label=\"myMRC 0.1\"/>" + 70 71 " <string label=\"(c) 2007 Sven Gregori and Damien Lefevre\"/>" + 71 " <command type=\"back\" label=\"O K\" opcode=\"0900\"/>" +72 " <command type=\"back\" label=\"Ok\" opcode=\"0" + Opcode.IOP_START + "\"/>" + 72 73 "</form>"; 73 74 } -
mymrc/trunk/Java-client/src/org/myMRC/events/Opcode.java
r15 r19 33 33 * client internal opcode group 09xx 34 34 */ 35 public static final String OP_PARSELIST = "0910"; 36 public static final int IOP_PARSELIST = 910; 37 public static final String OP_PARSRFORM = "0911"; 38 public static final int IOP_PARSEFORM = 911; 39 public static final int IOP_DISCONNECT = 991; 35 public static final int IOP_START = 900; 36 public static final int IOP_ABOUT_DIALOG = 901; 37 public static final String OP_PARSELIST = "0910"; 38 public static final int IOP_PARSELIST = 910; 39 public static final String OP_PARSRFORM = "0911"; 40 public static final int IOP_PARSEFORM = 911; 41 public static final int IOP_SETTINGS = 920; 42 public static final int IOP_SETTINGS_SAVE = 921; 43 public static final int IOP_CONNECT = 990; 44 public static final int IOP_DISCONNECT_CONF = 991; 45 public static final int IOP_DISCONNECT_FORCED = 992; 46 public static final int IOP_DISCONNECT = 993; 47 public static final int IOP_INT_EXIT_CONF = 998; 48 public static final int IOP_INT_EXIT = 999; 40 49 } -
mymrc/trunk/Java-client/src/org/myMRC/net/CommunicationController.java
r15 r19 105 105 106 106 } catch (ConnectionNotFoundException cnfe) { 107 /*108 * Event.execute() for EV_(RE)CONNECT will display an error in that109 * case, so no special handling necessary here.110 *111 * FUCK THAT!112 * FIXME!113 */114 107 isAlive = false; 115 108 throw new IOException(cnfe.getMessage()); // FIXME: this is just a temporary hack … … 198 191 requestTable.put(replyId, requester); 199 192 } 193 200 194 201 195 /* … … 249 243 250 244 try { 245 if (counter > MAX_UNRESPONDED_SENDS) { 246 throw new IOException("Maximum unresponded sends exceeded"); 247 } 248 251 249 /* finally! we can send it ;) */ 252 250 System.out.println("send: '" + sendBuf + "'"); 253 251 ostream.write(sendBuf.toString().getBytes()); 254 252 ostream.flush(); 253 counter++; 255 254 256 255 } catch (IOException ioe) { 257 256 //ioe.printStackTrace(); 258 Controller.getInstance().processInternalEvent(Opcode.IOP_DISCONNECT, null); 257 Controller.getInstance().processInternalEvent( 258 Opcode.IOP_DISCONNECT_FORCED, ioe.getMessage()); 259 259 } 260 260 } -
mymrc/trunk/Java-client/src/org/myMRC/parser/FormParser.java
r10 r19 41 41 if (parser.getEventType() == XmlPullParser.START_TAG) { 42 42 if (parser.getName().equalsIgnoreCase("form")) { 43 String label = parser.getAttributeValue(null, "label");44 form.setTitle( label);43 String title = parser.getAttributeValue(null, "title"); 44 form.setTitle(title); 45 45 46 46 while (!(parser.next() == XmlPullParser.END_TAG && … … 50 50 createFormItem(); 51 51 } 52 53 } else if (parser.getName().equalsIgnoreCase("command")) { 54 String label = parser.getAttributeValue(null, "label"); 55 String eventId = parser.getAttributeValue(null, "event"); 56 form.addEventCommand(eventId, label); 57 52 58 53 } else { 59 54 /* … … 163 158 if (cmdType != null) { 164 159 if (cmdType.equalsIgnoreCase("options")) { 165 160 form.addEventCommand(opcode, cmdLabel); 166 161 } 167 162 else if (cmdType.equalsIgnoreCase("back")) { -
mymrc/trunk/Java-client/src/org/myMRC/screen/FormScreen.java
r10 r19 121 121 if (command == backCommand) { 122 122 controller.processOutput(backOpcode, null); 123 123 124 124 } else { 125 125 for (int i = 0; i < commands.size(); i++) { … … 146 146 controller.processOutput(Opcode.OP_FORMVAL, value); 147 147 } 148 } 148 } 149 149 150 } else if (command == cmd.getCommand()) { 150 151 String opcodeIdx = cmd.getOpcode();
