Not logged in. · Lost password · Register
Forum: agsXMPP RSS
in google Talk
Page:  1  2  3  next
Avatar
CameronKloot #1
Member since Mar 2008 · 19 posts
Group memberships: Members
Show profile · Link to this post
Subject: Changeing acount picture
Hi,
How would I be able to change the picture of a provided gmail account?  So the user would log in to the application, select picture, and the picture would be changed.  Any help is appreciated.
Thanks,
Cameron
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
what you are looking for is avatars
You will find many threads with the search function for avatars. If the search does not help come back and we try to solve your problems.

Alex
Avatar
CameronKloot #3
Member since Mar 2008 · 19 posts
Group memberships: Members
Show profile · Link to this post
Ahha! I was searching pictures :P.
OK, so if I'm getting this right, I have to create a presence, add an avatar to it, and send it.  Right?  I know how to do it all except how to change the avatar to a hash string.  In the posts I found, there was no direct reference to it (or maybe I'm just stupid ;)  ).
Thanks
This post was edited on 2008-03-27, 16:07 by CameronKloot.
Avatar
Alex #4
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
There are different ways to do it. What most clients currently do is:

  • put a picture in your vcard
  • send the hash with the presence

  1. <presence from="user1" to="user2" >
  2. <status/>
  3. <x xmlns="vcard-temp:x:update">
  4. <photo>14370fff97373910a64095f35c3f123150314485</photo>
  5. </x>
  6. </presence>

if you get such a presence you can get the picture from the vcard of your contact and store it on your disc. You can use the hash as filename.
If the hash changes get the new picture.

Alex
Avatar
CameronKloot #5
Member since Mar 2008 · 19 posts
Group memberships: Members
Show profile · Link to this post
But how do you change the picture into a hash?  Like, how do you convert it?  Would you mind writing the code in C#?
Thanks

EDIT:
OK, I think I figured it out somewhat:
            VcardIq v = new VcardIq();
            v.Vcard.Photo = new Photo(textBox1.Text);
            Presence p = new Presence();
            Avatar a = new Avatar();
            a.Hash = v.Vcard.GetHashCode().ToString();
            p.AddChild(a);
is this the way to do it?

Edit #2 ;)
would adding xmpp.Send(p); send the presence?  What I want to happen  is run the code and my picture would change.  I wouldn't actually be creating a chat client, just a method of changing my picture.  Would this work?
This post was edited 2 times, last on 2008-03-27, 17:06 by CameronKloot.
Avatar
Alex #6
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The code looks correct except o the Hash.
You have to build a SHA1 Hash of the Image file as defined in RFC-3174

With a quick Google Search I can find many examples of building a SHA1 hash of a file
eg. http://www.codeproject.com/KB/files/dt_file_hasher.aspx

Alex
Avatar
Alex #7
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you also have to send the updated vcard with the image to the server.
You can find a Vcard example in the MiniClient.

Alex
Avatar
CameronKloot #8
Member since Mar 2008 · 19 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #6
I don't suppose there is any copy-paste code from a program that I could look over?  A chat program.
Thanks
Avatar
Alex #9
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
there are different open source clients based on agsXMPP. So take a look at them, eg. Xeus2.

Alex
Avatar
CameronKloot #10
Member since Mar 2008 · 19 posts
Group memberships: Members
Show profile · Link to this post
Xeus2 is in XML.  How long is this code?  Can you not just post a sample please?
Thanks
Avatar
Alex #11
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
no Xeus2 is written in c# based on agsXMPP.
http://xeus-messenger.blogspot.com/

For the time you need to find this functions in the source you can write your own functions. I think this is a job of only 10 minutes.

Alex
Avatar
CameronKloot #12
Member since Mar 2008 · 19 posts
Group memberships: Members
Show profile · Link to this post
OK, well I think I've come a little farther in my code. 

          byte[] imagebytes;
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                Image i = Image.FromFile(textBox1.Text);
                i.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                imagebytes = ms.ToArray();
            }
            VcardIq v = new VcardIq();
            v.Vcard.Photo = new Photo(textBox1.Text);
            Presence p = new Presence();
            p.Status = xmpp.Status;
            p.Show = xmpp.Show;
            Avatar a = new Avatar();
            a.Hash = agsXMPP.util.Hash.HexToString(imagebytes);
            p.AddChild(a);
            xmpp.Send(v);
            xmpp.Send(p);

I think I'm pretty close to the solution, but something is still not working.  Could someone shed light?
Thanks
Avatar
Alex #13
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
this code looks correct to me.
You said before that you don't want to write a client, but only change the avatar. The avatar is only shown when all clients sends the x tag with the hash in the presence.
Can this be the problem?

Alex
Avatar
Alex #14
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
did you try it also on another server than the Gmail server?
Avatar
CameronKloot #15
Member since Mar 2008 · 19 posts
Group memberships: Members
Show profile · Link to this post
I'm not really sure what that means, and I have not tried it with another server.  When I run the code above, the account actually goes offline, I don't know why, but it has something to do with the presence not working.  When I take out the avatar code, the account still goes offline.  The avatar code might actually work, but since the account goes off, I can't tell.
Thanks
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Page:  1  2  3  next
Forum: agsXMPP RSS