Source code: plugins/YahooService/YahooService.java
1 /*
2 This file is part of DeXter - Java Internet Communication Solution
3 Copyright (c) 2002 Tobias Riemer
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library 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 Lesser General Public
16 License 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 /*
21 * YahooService.java
22 *
23 * Created on 03. Oktober 2002, 11:39
24 */
25
26 package plugins.YahooService;
27
28 /**
29 *
30 * @author Tobias Riemer
31 */
32
33 import dexter.core.*;
34 import java.net.*;
35 import java.io.*;
36
37 public class YahooService extends DefaultService {
38
39 Socket socket;
40 BufferedReader in;
41 PrintStream out;
42
43 private String ip = "216.136.233.128"; //cs.yahoo.com
44 private int port = 5050;
45
46 /** Creates a new instance of YahooService */
47 public YahooService() {
48 super("YahooService");
49 try {
50 socket = new Socket(ip,port);
51 in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
52 out = new PrintStream(socket.getOutputStream());
53
54 String user = "tobias_2beers";
55
56 char c9 = 9;
57 char c0 = 0;
58 char ce = 0x0e;
59 char cc0 = 0xc0;
60 char c80 = 0x80;
61
62 char len = (char) (5 + user.length());
63
64 String sep = "" + cc0 + c80;
65
66
67 String s = "YMSG" + c9
68 + c0 + c0 + c0 + c0
69 + len + c0 + 'W'
70 + c0 + c0 + c0 + c0
71 + c0 + c0 + c0 + c0
72 + '1' + sep
73 + user + sep;
74
75 output("Sendding",s);
76
77 out.println(s);
78
79 s = in.readLine();
80 output("Receiving",s);
81 } catch (Exception e) {
82 System.out.println("Send error " + e);
83 e.printStackTrace();
84 }
85 }
86
87 public void output(String s1, String s2) {
88 System.out.println(s1 + " " + s2);
89 if (s2 == null) return;
90 for (int i=0;i<s2.length();i++) {
91 System.out.print(Integer.toHexString((int) s2.charAt(i)) + " ");
92 }
93 System.out.println(" ");
94 }
95
96 public void doRun() {
97 throw new UnsupportedOperationException("doRun is not yet implemented");
98 }
99
100 public static void main(String[] args) {
101 new YahooService();
102 }
103 }