Blablabla

Final Report of FSC 2010

Posted by kay21s in August 16, 2010

The Fedora Summer Coding project — Libyahoo2 chat room support has been completed.
My code is on the github, Link : http://github.com/kay21s/Libyahoo2

The work before mid-term evaluation:

  1. Implement the chat logon message.
  2. Implement the chat join message.
  3. Extract the URL of the verification image in the received message, using callback function to let the user input the verification code. Then using the http functions inside the Libyahoo2 to send the identifying code to the server.
  4. Implement the logout message.
  5. Updated some fields in the previous version
  6. Write a detailed documentation of the chat room support and the chat room-related YMSG protocol.

Work from mid-term evaluation to final:

  1. Add a new connection type: YAHOO_CAPTCHA_CONNECTION to handle the connection of getting captcha seprately, and parse the response from the server to find out whether the words typed by the user is correct. If not, find out the URL of the new captcha and present it to client.
  2. Get chat room categories.  Send request to the server, and handle this connection by a specific parser to parse the XML content of the response which are chat room categories.
  3. Get chat room list. For a specified chat room category, when we want to get all the chat rooms belong to that category, we send request to the server. Just the same as getting chat room categories, we add a parser to parse all the information about the chat rooms, including user numbers, user with webcams, user can talk through microphones and so on.
  4. When I am implementing the captchat_connection, Mentor told me that it should be better to implement a function to parse a HTTP packet and turn its status code, method-lines, contents and such information into a structured block to facilitate later usage. So I implement this function and use it in the first work to find out the new URL of the captcha which is the value of the “location” method line.
  5. Implement two interfaces in getting chat room categories and chat room list. After the first time we get the list, we store it in a linked list for later use. The client can choose whether to use the cached one or a new refreshed one.

In this process, I have learned quite a lot. Some good skills in programming, some useful tools and the way of communicating with community.

I can do it better if I tried to understand other parts in the code and get some knowledge on the usual function tools that are used. So that I can keep consistent with the origin style. What’s more, It is better that the community organizer can be a bit more efficient, such as having a firm deadline, reply to questions ASAP and so on.

I’d like to say thanks to my mentor, Siddhesh Poyarekar. You are nice and patient, never tires of answering my questions, even it sounds fool sometimes. And Philip Tellis, thank you for your suggestions on libyahoo2-dev mailing list. Vera, thanks for your great work and your support, I appreciate it more than I can say.

Turn a raw HTTP response packet into a structured one

Posted by kay21s in July 25, 2010

This is extracted as a function which takes a raw packet as the input and gives out a structured one.

The structured packet has the following fields: HTTP version(1.0/1.1), HTTP response number, all name-value pairs and the content. Now we no longer use the strstr() or strchr() to locate a field or the information we want which is also fallible.

In this way, the application can use it to get the information they need by using the fields in the struct directly. It is more convenient for not only the captcha processing function to find the location field but also for other functions which needs information from the HTTP packet.

Getting chat rooms for a dedicated categories

Posted by kay21s in July 24, 2010

In the previous blog, it can get all categories via “CHL 0″, then the libyahoo2 will receive the response from server and handle it to the sample client which will analyze its XML content and displays all the categories. Each category is given an ID.

Now using the ID of a category, such as 1015, can get all the chat rooms in that category. “CHL 1015″ command can be used. It will display the information of the each chat room, such as user number, number of users with webcam and so on.

In the process, I have encountered one problem which have puzzled me for a long time: the malloc got to be wrong when allocating a bulk of memory. At last, I have found that’s because the strcpy operation before the malloc has copied a string to a memory space smaller than the size of the string, thus it destroys the stack of malloc and lead to the errors.

Getting chat room categories has been implemented

Posted by kay21s in July 19, 2010

Getting chat room categories is an important function,  since users can see the categories and then can select one they are most interested in to enter.

At first, I defined a struct myself to store the chat room category information. My mentor told me that it is better to use the already-defined structure, struct YList. Then I implemented it with the YList struct and store the specified information in a self-defined structure which is stored in the data field of the YList struct, it is a general way to store information.

In the implementation, the prev pointer of YList is used as a pointer to the subcategories of the current one.  Now using CHL 0 can get all the categories of Yahoo chat rooms.

Posted by kay21s in July 18, 2010

Thanks to Philip Tellis, after I have send a query in the dev-libyahoo2 mailling list, he pointed that the URL of the captcha image should be found in the Location field of the HTTP header, but not the HTTP content. Since the HTTP content may not be sent, the Location field is a better way in a HTTP 301 response.

I have implemented it in this way, thanks to his suggestions!

CAPTCHA has been implemented

Posted by kay21s in July 13, 2010

Thanks for my mentor’s help, this function has been completed.

When accessing a chat room, yahoo sends  a image and only is given the correct captcha will be allowed to enter the chat room.  If what is typed in is wrong, yahoo will respond with a URL of  a new image to verify again. Previously, we did not handle the situation when what is typed is wrong.

I add a new connection type YAHOO_CAPTCHA_CONNECTION to handle the connection used for post the captcha and parse the responds from the server. There comes a problem when I am writing the code, I kept on receiving the same packet sent from the server after typing the wrong captcha and do not know why. Mentor told me to close the connection each time before sending the new captcha again because HTTP 1.1 does not close its connection automatically.

Now the lib can kept on receiving the response and handle the new URL to the client after a wrong captcha is typed by the user until a correct one is received.

Mid-term report

Posted by kay21s in June 28, 2010

Until now, most of the project has been completed.

I have finished the following works in the passing days:

1. Implement the chat logon message.

2. Implement the chat join message.

3. Extract the URL of the verification image in the received message, using callback function to let the user input the verification code. Then using the http functions inside the Libyahoo2 to send the identifying code to the server.

4. Implement the logout message.

5. Updated some fields in the previous version

6. Write a detailed documentation of the chat room support and the chat room-related YMSG protocol.

The YMSG protocol

Posted by kay21s in June 6, 2010

I spent the week trying to understand the chat room protocol dumps I got from the yahoo messenger program. I have documented it in the $(top_srcdir)/doc/ymsg-chatroom.txt

The first job going to finish: the login process.

1.Chat online. A few new keys, such as language and country, are added and some keys in the previous version are dropped.

2.Chat login. Different from the previous version, yahoo messenger now has a mechanism to prevent spam and bot. A image URL is sent from the server, this URL should be handed to client.  The client gets the image and gets the user’s input. Library should have a function which is called by the client to send the characters user typed in.

Exit a Chat Room in YMSG 17

Posted by kay21s in June 5, 2010

Chat Logout

Service : Chat Logout (160   0xa0)

Client –> Server

  • 1 : username
  • 1005 : (number)

Server –> Client

  • 1 : username
  • 1005 : (number) <same with the number sent to server>
  • 302 : 10019
  • 10019 : username
  • 303 : 10019

Messages after Joining the Chat Room

Posted by kay21s in June 5, 2010

1. Keep Alive

Service  :  Keep Alive(138   0x8a)

Client –> Server

  • 0 : username

2. Comment

Service : Comment(168   0xa8)

Client –> Server

  • 1 : username
  • 104: #ChatRoom(China:1)
  • 124 : 1
  • 117 : (Content)

Server –> Client

  • 104 : #ChatRoom(China:1)
  • 109 : (From) Yahoo/username
  • 117 : (Content)
  • 124 : 1

3. Chat Join

Service : Chat Join (152   0×98)

Server –> Client :

  • 104 : #ChatRoom(China : 1)
  • 105 : (Information from the chat room)
  • 108 : 1
  • 109 : username(who is joining)
  • 113 : (number)

4. Chat Exit

Service : Chat Exit(155   0x9b)

Server –> Client

  • 104 : #ChatRoom(China:1)
  • 108 : 1
  • 109 : username(who is leaving)
  • 113 : (number)