View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.plugin.overnet.net.msg.core;
21  
22  import java.nio.ByteBuffer;
23  
24  import org.apache.log4j.Logger;
25  
26  public class MessageFactory
27  {
28  
29      //--- Data Field(s) ---
30  
31  	public static final byte CORE_CLIENT_STATS = (byte)175;
32  	public static final byte CORE_CONNECTED_TO = (byte)182;
33  	public static final byte CORE_DISCONNECTED = (byte)183;
34  	public static final byte CORE_ED_NEW_SEARCH_RESULT = (byte)145;
35  	public static final byte CORE_ED_SEARCH_RESULT = (byte)146;
36  	public static final byte CORE_ERROR_MSG = (byte)181;
37  	public static final byte CORE_EXTENDING_SEARCH = (byte)185;
38  	public static final byte CORE_FILECHUNK = (byte)253;
39  	public static final byte CORE_FILECOMPLETE = (byte)254;
40  	public static final byte CORE_FRIEND_LIST = (byte)171;
41  	public static final byte CORE_FRIEND_LIST_UPDATE = (byte)196;
42  	public static final byte CORE_HASHING = (byte)195;
43  	public static final byte CORE_NEW_SEARCH_RESULTS = (byte)187;
44  	public static final byte CORE_NEW_UPLOAD_SLOT = (byte)192;
45  	public static final byte CORE_REMOVE_UPLOAD = (byte)191;
46  	public static final byte CORE_SERVER_LIST = (byte)170;
47  	public static final byte CORE_SET_SERVER_STATS = (byte)184;
48  	public static final byte CORE_USER_FILES = (byte)194;
49  	public static final byte GUI_ADD_SERVER = (byte)222;
50  	public static final byte GUI_CONNECT = (byte)200;
51  	public static final byte GUI_DELETE_SERVER = (byte)221;
52  	public static final byte GUI_DISCONNECT = (byte)201;
53  	public static final byte GUI_EXSEARCH = (byte)203;
54  	public static final byte GUI_EXSEARCH_USER = (byte)206;
55  	public static final byte GUI_GET_CLIENT_STATS = (byte)228;
56  	public static final byte GUI_GET_FRIENDLIST = (byte)214;
57  	public static final byte GUI_MORESEARCH = (byte)204;
58  	public static final byte GUI_SEARCH_USER = (byte)205;
59  	public static final byte GUI_SETPRI_DOWNLOAD = (byte)211;
60  	public static final byte GUI_SETPRI_SERVER = (byte)223;
61  	public static final byte GUI_SET_SHARE_DIRS = (byte)216;
62  	public static final byte GUI_SET_UPLOAD_PRIORITY = (byte)229;
63  	public static final byte GUI_STOP_DL_STATUS = (byte)218;
64  	public static final byte GUI_STOP_UL_STATUS = (byte)220;
65  	public static final byte GUI_VIEW_FRIEND_FILES = (byte)212;
66  
67  
68  	private static Logger logger = Logger.getLogger(MessageFactory.class);
69  	
70      //--- Constructor(s) ---
71  
72      //--- Method(s) ---
73  
74      public static OvernetCoreMessage create(byte type, ByteBuffer buffer) 
75      {
76  		OvernetCoreMessage msg = null;
77  		
78  		switch (type) {
79  		
80  		case ChangeUploadSlotMessage.TYPE:
81  			msg = new ChangeUploadSlotMessage(buffer);
82  			break;
83  		case CORE_CLIENT_STATS:
84  			break;
85  		case CORE_CONNECTED_TO:
86  			break;
87  		case CORE_DISCONNECTED:
88  			break;
89  		case GapsMessage.TYPE:
90  			msg = new GapsMessage(buffer);
91  			break;
92  		case DownloadStatusMessage.TYPE:
93  			msg = new DownloadStatusMessage(buffer);
94  			break;
95  		case CORE_ED_NEW_SEARCH_RESULT:
96  			// donkey only
97  			logger.debug("donkey old result?");
98  			break;
99  		case CORE_NEW_SEARCH_RESULTS:
100 			// onvernet style
101 			logger.debug("overnet multiple results");
102 			break;
103 		case CORE_ED_SEARCH_RESULT:
104 			// donkey only
105 			logger.debug("donkey single result");
106 			break;
107 		case SearchResultMessage.TYPE:
108 			// overnet style
109 			msg = new SearchResultMessage(buffer);
110 			break;
111 		case CORE_ERROR_MSG:
112 			break;
113 		case CORE_EXTENDING_SEARCH:
114 			break;
115 		case CORE_FILECHUNK:
116 			break;
117 		case CORE_FILECOMPLETE:
118 			break;
119 		case CORE_FRIEND_LIST:
120 			break;
121 		case CORE_FRIEND_LIST_UPDATE:
122 			break;
123 		case CORE_HASHING:
124 			break;
125 		case NewDownloadMessage.TYPE:
126 			msg = new NewDownloadMessage(buffer);
127 			break;
128 		//  case NewUploadMessage.TYPE:
129 //  			msg = new NewUploadMessage(buffer);
130 //  			break;
131 		case CORE_NEW_UPLOAD_SLOT:
132 			break;
133 		case OptionsMessage.TYPE:
134 			msg = new OptionsMessage(buffer);
135 			break;
136 		case RemoveDownloadMessage.TYPE:
137 			msg = new RemoveDownloadMessage(buffer);
138 			break;
139 		case CORE_REMOVE_UPLOAD:
140 			break;
141 		case RemoveUploadSlotMessage.TYPE:
142 			msg = new RemoveUploadSlotMessage(buffer);
143 			break;
144 		case CORE_SERVER_LIST:
145 			break;
146 		case CORE_SET_SERVER_STATS:
147 			break;
148 		case SharedDirsMessage.TYPE:
149 			msg = new SharedDirsMessage(buffer);
150 			break;
151 		case SharedFilesMessage.TYPE:
152 			msg = new SharedFilesMessage(buffer);
153 			break;
154 		case CoreStatusMessage.TYPE:
155 			msg = new CoreStatusMessage(buffer);
156 			break;
157 		case UploadStatusMessage.TYPE:
158 			msg = new UploadStatusMessage(buffer);
159 			break;
160 		case CORE_USER_FILES:
161 			break;
162 		}
163 		return msg;
164 	}
165 }