Exemple #1
0
        /// <summary>
        /// Wysyla do servera zapytanie o uzytkownika
        /// </summary>
        /// <param name="gaduUser">Uzytkownik, ktorego chcemy znalezc</param>
        public void Search(GaduUser gaduUser)
        {
            GaduPacketHeader   gaduPacketHeader   = new GaduPacketHeader();
            GaduPacketPubDir50 gaduPacketPubDir50 = new GaduPacketPubDir50();

            gaduPacketHeader.Type   = GaduPacketConstans.GG_PUBDIR50_REQUEST;
            gaduPacketPubDir50.Type = GaduPacketConstans.GG_PUBDIR50_SEARCH;
            gaduPacketPubDir50.Seq  = (int)DateTime.Now.Ticks;
            gaduPacketPubDir50.Data = gaduUser.getPubDirString();
            gaduPacketHeader.Length = gaduPacketPubDir50.getSize();
            gaduSender.sendPacket(gaduPacketHeader);
            gaduSender.sendPacket(gaduPacketPubDir50);
        }
Exemple #2
0
        /// <summary>
        /// Parsuje cala list kontaktow zwrocona w postaci jednego duzego zlepka charow
        /// </summary>
        /// <param name="s">String z, ktorego pobierzemy dane</param>
        /// <returns>Tablica obiektow klasy GaduUser</returns>
        public static List <GaduUser> ParseUserListString(String s)
        {
            try
            {
                List <GaduUser> list = new List <GaduUser>();

                String[] vals = s.Split(';');
                String   user;
                for (int i = 0; i < vals.Length; i += 13)
                {
                    user = String.Empty;
                    for (int j = i; j < ((i + 13) >= vals.Length ? vals.Length : i + 13); j++)
                    {
                        user += vals[j] + ';';
                    }

                    GaduUser gaduUser = new GaduUser();
                    string[] vals2    = user.Split(';');
                    if (vals2.Length > 13)     // kazdy uzytkownik musi miec przynajmiej 14 pol, jezeli tyle nie ma
                    {                          // uznajemy ze cos jest nie tak i nie dodajemy go
                        gaduUser.Name        = vals2[0];
                        gaduUser.LastName    = vals2[1];
                        gaduUser.Nick        = vals2[2];
                        gaduUser.VisibleNick = vals2[3];
                        Int32.TryParse(vals2[4], out gaduUser.mobile_phone);
                        gaduUser.Group = vals2[5];
                        Int32.TryParse(vals2[6], out gaduUser.uin);
                        gaduUser.Email = vals2[7];
                        Byte.TryParse(vals2[8], out gaduUser.avail);
                        gaduUser.PathAvail   = vals2[9];
                        gaduUser.Message     = vals2[10];
                        gaduUser.PathMessage = vals2[11];
                        Byte.TryParse(vals2[12], out gaduUser.hidden);
                        Int32.TryParse(vals2[13], out gaduUser.phone);

                        list.Add(gaduUser);
                    }
                }

                return(list);
            }
            catch (Exception exp)
            {
                throw new GaduUserException(exp.Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// Parsuje string tyczacy sie katalogu publicznego i zwraca liste obiektow klasy GaduUser
        /// </summary>
        /// <param name="s">String z, ktorego pobierzemy dane</param>
        /// <returns>Lista obiektow klasy GaduUser</returns>
        public static List <GaduUser> ParsePubDirString(String s)
        {
            try
            {
                List <GaduUser> list = new List <GaduUser>();
                GaduUser        gaduUser;
                String[]        users;
                String[]        vars;
                users = s.Split(new String[] { "\0\0" }, StringSplitOptions.None);

                for (int i = 0; i < users.Length; i++)
                {
                    gaduUser = new GaduUser();
                    vars     = users[i].Split('\0');
                    for (int j = 0; j < vars.Length; j += 2)
                    {
                        switch (vars[j])
                        {
                        case "FmNumber":
                            gaduUser.Uin = Convert.ToInt32(vars[j + 1]);
                            break;

                        case "firstname":
                            gaduUser.Name = vars[j + 1];
                            break;

                        case "lastname":
                            gaduUser.LastName = vars[j + 1];
                            break;

                        case "nickname":
                            gaduUser.Nick = vars[j + 1];
                            break;

                        case "birhyear":
                            gaduUser.BirthYear = Convert.ToInt32(vars[j + 1]);
                            break;

                        case "city":
                            gaduUser.City = vars[j + 1];
                            break;

                        case "gender":
                            gaduUser.Gender = Convert.ToInt32(vars[j + 1]);
                            break;

                        case "ActiveOnly":
                            gaduUser.ActiveOnly = Convert.ToInt32(vars[j + 1]);
                            break;

                        case "familyname":
                            gaduUser.FamilyName = vars[j + 1];
                            break;

                        case "familycity":
                            gaduUser.FamilyCity = vars[j + 1];
                            break;

                        case "fmstart":
                            gaduUser.FmStart = Convert.ToInt32(vars[j + 1]);
                            break;
                        }
                    }
                    list.Add(gaduUser);
                }

                return(list);
            }
            catch (Exception exp)
            {
                throw new GaduUserException(exp.Message);
            }
        }