Beispiel #1
0
        public void Xmpp_OnListGroup(object sender, string[] rooms)
        {
            if (rooms.Length == 0)
            {
                return;
            }

            List <AppCore.User> groups = new List <AppCore.User>();

            foreach (string room in rooms)
            {
                AppCore.User gUser = userService.turnGroupToUserToList(room, room);
                groups.Add(gUser);

                //if (room.Equals(rooms[rooms.Length - 1]))
                //{
                if (context != null)
                {
                    BaseAppCompatActivity o = (BaseAppCompatActivity)context;
                    o.saveSeachGroups(groups);
                    this.App.Xmpp.JoinGroup(room);
                }

                //}
            }
        }
Beispiel #2
0
        public AppCore.User turnGroupToUserToList(string groupId, string groupName)
        {
            AppCore.User user = new AppCore.User();
            user.isGroup = true;
            user.Jid     = groupId;
            user.Nick    = groupName;

            return(user);
        }
Beispiel #3
0
        public AppCore.User removeRepetUsers(AppCore.User user)
        {
            List <AppCore.User> users = new List <AppCore.User>();

            foreach (AppCore.User u in user.users)
            {
                if (!users.Any(o => o.Jid.Equals(u.Jid)))
                {
                    users.Add(u);
                }
            }

            if (users.Count > 0)
            {
                user.users = users;
            }

            return(user);
        }
Beispiel #4
0
        public void Xmpp_OnJoinGroup(object sender, string roomJid)
        {
            Messaging.Log.Info("joined a room " + roomJid);
            if (roomJid != null)
            {
                List <AppCore.User> userGroups = LegionUtils.getGroupsTempToList(AppPreferences.GROUPS_TEMP, appPreferences);
                AppCore.User        group      = new AppCore.User();
                group.Jid     = roomJid + "@" + AppCore.Utils._MUS_SERVER;
                group.isGroup = true;

                if (userGroups.Any(x => x.Jid != (group.Jid)))
                {
                    userGroups.Add(group);
                    if (context != null)
                    {
                        BaseAppCompatActivity o = (BaseAppCompatActivity)context;
                        o.saveSeachGroups(userGroups);
                    }
                }
            }
        }
Beispiel #5
0
        public AppCore.User getValidUser(Matrix.Xmpp.Vcard.Vcard vc, string resourceName)
        {
            AppCore.User contac = new AppCore.User();
            contac.Jid = vc.Jid;

            if (vc.Nickname != null && vc.Nickname != "")
            {
                contac.username = vc.Nickname;
                contac.First    = vc.Fullname;

                if (vc.GetTagXElement("Phone") != null)
                {
                    contac.Phone = vc.GetTagXElement("Phone").ToString();
                }

                if (vc.Photo != null)
                {
                    if (vc.Photo.Binval != null)
                    {
                        contac.Photo = LegionUtils.bitmapToBase64(vc.Photo.Binval);
                        appPreferences.saveKey(contac.username + "_ICON", contac.Photo);
                    }
                }
            }
            else
            {
                vc.Nickname     = vc.Jid.ToString().Replace("@" + resourceName, "");
                contac.username = vc.Nickname;
                if (vc.Photo != null)
                {
                    if (vc.Photo.Binval != null)
                    {
                        contac.Photo = LegionUtils.bitmapToBase64(vc.Photo.Binval);
                    }
                }
            }

            return(contac);
        }
Beispiel #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            this.callType = this.Intent.GetStringExtra("callType");
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);
            SetContentView(Resource.Layout.Video);
            Layout          = (RelativeLayout)FindViewById(Resource.Id.layout);
            ActivityService = ActivityService.GetInstance;
            if (friend == null)
            {
                if (this.callType.Equals("incoming"))
                {
                    friend          = new AppCore.User();
                    friend.Jid      = this.Intent.GetStringExtra("userChat");
                    friend.username = LegionUtils.GetUserNameClear(friend.Jid);
                }
                else
                {
                    friend = LegionUtils.getUserson(Intent.GetStringExtra("userChat"));
                }
            }

            //ActivityService.GetInstance.App.Xmpp.OnReceiveSessionAccept += (sender, e) => {
            //	Log.Info("Success connection");

            //	//RunOnUiThread(() =>
            //	//		showConnectionVideo(true)
            //	//		 );

            //};



            //Bgconnection = (ImageView)FindViewById(Resource.Id.
            //                                       bgconnection);
            //avatar = (ImageView)FindViewById(Resource.Id.avatarFriend);
            if (friend.Photo != null)
            {
                //Bitmap bitmap = xmppFace.Base64ToBitmap(friend.Photo);
                //var d = new CircleDrawable(bitmap);
                //avatar.SetBackgroundDrawable(d);
            }
            //TxUserName = (TextView)FindViewById(Resource.Id.userNameFriend);
            //TxUserName.Text = friend.username;
            //TxConnection = (TextView)FindViewById(Resource.Id.connect);

            LeaveButton = (ImageButton)FindViewById(Resource.Id.leaveButton);

            // Load native libraries.
            if (!Build.CpuAbi.ToLower().Contains("x86") && !Build.CpuAbi.ToLower().Contains("arm64"))
            {
                Java.Lang.JavaSystem.LoadLibrary("audioprocessing");
                Java.Lang.JavaSystem.LoadLibrary("audioprocessingJNI");
            }
            Java.Lang.JavaSystem.LoadLibrary("opus");
            Java.Lang.JavaSystem.LoadLibrary("opusJNI");
            Java.Lang.JavaSystem.LoadLibrary("vpx");
            Java.Lang.JavaSystem.LoadLibrary("vpxJNI");

            LeaveButton.Click += new EventHandler(LeaveButton_Click);

            Messaging.Log.Debug("VideoActivity adding event handler Xmpp_OnReceiveSessionTerminate");
            //oadXmppConnect(this);
            ActivityService.GetInstance.App.Xmpp.OnReceiveSessionTerminate += Xmpp_OnReceiveSessionTerminate;
            //ActivityService.GetInstance.App.Xmpp.OnReceiveSessionInitiate += Xmpp_OnReceiveSessionInitiate;

            // For demonstration purposes, use the double-tap gesture
            // to switch between the front and rear camera.
            GestureDetector = new GestureDetector(this, new OnGestureListener(ActivityService.GetInstance.App));

            // Preserve a static container across
            // activity destruction/recreation.
            var c = (RelativeLayout)FindViewById(Resource.Id.container);

            if (Container == null)
            {
                Container = c;

                Toast.MakeText(this, "Double tap to switch camera.", ToastLength.Short).Show();
            }
            Layout.RemoveView(c);

            if (!LocalMediaStarted)
            {
                StartLocalMedia();
            }
        }
Beispiel #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.VoiceCall);
            this.callType = this.Intent.GetStringExtra("callType");
            if (friend == null)
            {
                if (this.callType.Equals("incoming"))
                {
                    friend          = new AppCore.User();
                    friend.Jid      = this.Intent.GetStringExtra("userChat");
                    friend.username = LegionUtils.GetUserNameClear(friend.Jid);
                }
                else
                {
                    friend = LegionUtils.getUserson(Intent.GetStringExtra("userChat"));
                }
            }
            App      = App.Instance;
            xmppFace = new XmppFacade();
            App.Xmpp.OnReceiveSessionAccept += (sender, e) =>
            {
                Log.Info("Success connection");
                timer.Interval = 1000;
                timer.Elapsed += OnTimedEvent;
                timer.Enabled  = true;
            };

            Layout       = (RelativeLayout)FindViewById(Resource.Id.layout);
            Bgconnection = (ImageView)FindViewById(Resource.Id.
                                                   bgconnection);
            avatar = (ImageView)FindViewById(Resource.Id.avatarFriend);
            if (friend.Photo != null)
            {
                Bitmap bitmap = xmppFace.Base64ToBitmap(friend.Photo);
                var    d      = new CircleDrawable(bitmap);
                avatar.SetBackgroundDrawable(d);
            }
            TxUserName      = (TextView)FindViewById(Resource.Id.userNameFriend);
            TxUserName.Text = friend.username;
            TxConnection    = (TextView)FindViewById(Resource.Id.time);

            LeaveButton = (ImageButton)FindViewById(Resource.Id.leaveButton);

            // Load native libraries.
            if (!Build.CpuAbi.ToLower().Contains("x86") && !Build.CpuAbi.ToLower().Contains("arm64"))
            {
                Java.Lang.JavaSystem.LoadLibrary("audioprocessing");
                Java.Lang.JavaSystem.LoadLibrary("audioprocessingJNI");
            }
            Java.Lang.JavaSystem.LoadLibrary("opus");
            Java.Lang.JavaSystem.LoadLibrary("opusJNI");
            Java.Lang.JavaSystem.LoadLibrary("vpx");
            Java.Lang.JavaSystem.LoadLibrary("vpxJNI");

            LeaveButton.Click += new EventHandler(LeaveButton_Click);

            Messaging.Log.Debug("VoiceCallActivity adding event handler Xmpp_OnReceiveSessionTerminate");
            //loadXmppConnect(this);
            //App.Instance.Xmpp.OnReceiveSessionTerminate += Xmpp_OnReceiveSessionTerminate;
            //App.Instance.Xmpp.OnReceiveSessionInitiate += Xmpp_OnReceiveSessionInitiate;


            if (!SignallingStarted)
            {
                StartSignalling();
            }

            if (!LocalMediaStarted)
            {
                StartLocalMedia();
            }
        }
Beispiel #8
0
 public AppCore.User removeNullUsersJidUnsername(AppCore.User user)
 {
     return(removeRepetUsers(user));
 }