rgadu 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/gg.rb +34 -8
  2. metadata +4 -3
data/lib/gg.rb CHANGED
@@ -38,14 +38,18 @@ class GG
38
38
  0x1f => 'LLa8a21a43'}
39
39
 
40
40
  =begin rdoc
41
- Tworzy nowy obiekt GG i loguje sie na serwerze uzywajac numeru *uin* i hasla *password*. Dodatkowe parametry to: :server => serwer GG, :port => port na serwerze GG, :dccport => port dla polaczen bezposrednich, :contacts => tablica z lista kontaktow, :version => wersja protokolu.
41
+ Tworzy nowy obiekt GG i loguje sie na serwerze uzywajac numeru *uin* i hasla *password*. Dodatkowe parametry to: :server => serwer GG, :port => port na serwerze GG, :dccport => port dla polaczen bezposrednich, :contacts => tablica z lista kontaktow, :status => poczatkowy status, :description => poczatkowy opis, :friendsonly - tryb tylko dla przyjaciol, :version => wersja protokolu.
42
42
  =end
43
43
  def initialize(uin, password, params={})
44
44
  server = params[:server] || '217.17.45.146'
45
45
  port = params[:port] || 8074
46
- dccport = params[:dccport]
46
+ dccport = params[:dccport] || 0
47
47
  contacts = params[:contacts] || []
48
+ status = params[:status] || :avail
49
+ description = params[:description]
50
+ friendsonly = params[:friendsonly] ? true : false
48
51
  version = (params[:version] || 6.0).to_f
52
+
49
53
  @uin=uin
50
54
  @dccport=dccport
51
55
  @socket=TCPSocket.new(server, port)
@@ -54,7 +58,7 @@ Tworzy nowy obiekt GG i loguje sie na serwerze uzywajac numeru *uin* i hasla *pa
54
58
  raise "Packet not recognized"
55
59
  end
56
60
  seed=read_body(length, 'L')[0]
57
- if dccport
61
+ if dccport > 0
58
62
  @dcc = DCCServer.new(dccport, uin)
59
63
  localip=@socket.addr[3].split('.').collect {|x| x.to_i }.pack('C4').unpack('L')[0]
60
64
  else
@@ -69,12 +73,28 @@ Tworzy nowy obiekt GG i loguje sie na serwerze uzywajac numeru *uin* i hasla *pa
69
73
  else
70
74
  protocol = 0x20
71
75
  end
76
+ if description
77
+ status = TO_STATUS_DESCRIPTION[status] or raise "Wrong status"
78
+ else
79
+ status = TO_STATUS[status] or raise "Wrong status"
80
+ end
81
+ if friendsonly
82
+ status = status | 0x8000
83
+ end
72
84
  if version >= 7
73
85
  hash = Digest::SHA1.digest(password + [seed].pack('L'))
74
- write(0x19, 'LCa64LLCLSLSCC', uin, 0x02, hash, 0x02, protocol, 0x00, localip, dccport, localip, dccport, 0x00, 0xbe)
86
+ if description
87
+ write(0x19, 'LCa64LLCLSLSCCa*C', uin, 0x02, hash, status, protocol, 0x00, localip, dccport, localip, dccport, 0x00, 0xbe, description, 0)
88
+ else
89
+ write(0x19, 'LCa64LLCLSLSCC', uin, 0x02, hash, status, protocol, 0x00, localip, dccport, localip, dccport, 0x00, 0xbe)
90
+ end
75
91
  else
76
92
  hash = gg_login_hash(password, seed)
77
- write(0x15, 'LLLLCLSLSCC', uin, hash, 0x02, 0x20, 0x00, localip, dccport, localip, dccport, 0x00, 0xbe)
93
+ if description
94
+ write(0x15, 'LLLLCLSLSCCa*C', uin, hash, status, 0x20, 0x00, localip, dccport, localip, dccport, 0x00, 0xbe, description, 0)
95
+ else
96
+ write(0x15, 'LLLLCLSLSCC', uin, hash, status, 0x20, 0x00, localip, dccport, localip, dccport, 0x00, 0xbe)
97
+ end
78
98
  end
79
99
  type, length = read_header
80
100
  read_body(length)
@@ -128,14 +148,20 @@ Wysyla wiadomosc *message* do *uin*.
128
148
  end
129
149
 
130
150
  =begin rdoc
131
- Zmienia status i opcjonalnie ustawia opis. Status powinien byc jednym z symboli: :avail, :busy, :invisible, :notavail
151
+ Zmienia status, opcjonalnie ustawia opis i tryb tylko dla przyjaciol. Status powinien byc jednym z symboli: :avail, :busy, :invisible, :notavail
132
152
  =end
133
- def status(status, description=nil)
153
+ def status(status, description=nil, friendsonly=false)
134
154
  if description
135
155
  status_id = TO_STATUS_DESCRIPTION[status] or raise "Wrong status"
136
- write(0x02, 'La*C', status_id, description, 0) if status_id
137
156
  else
138
157
  status_id = TO_STATUS[status] or raise "Wrong status"
158
+ end
159
+ if friendsonly
160
+ status_id = status_id | 0x8000
161
+ end
162
+ if description
163
+ write(0x02, 'La*C', status_id, description, 0) if status_id
164
+ else
139
165
  write(0x02, 'L', status_id) if status_id
140
166
  end
141
167
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: rgadu
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.0
7
- date: 2007-09-23 00:00:00 +02:00
6
+ version: 0.2.1
7
+ date: 2007-12-21 00:00:00 +01:00
8
8
  summary: A simple pure-Ruby implementation of the Gadu-Gadu protocol.
9
9
  require_paths:
10
10
  - lib
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - bl4
30
31
  files: