Exemplo n.º 1
0
        private void StartStack()
        {
            iUserLogListener = new AndroidUserLogListener();
            UserLog.AddListener(iUserLogListener);
            iTraceListener = new AndroidTraceListener();
            Trace.AddListener(iTraceListener);
            iWifiManager = (WifiManager)GetSystemService(Context.WifiService);
            if (iWifiManager != null)
            {
                iWifiLock = iWifiManager.CreateWifiLock("myWifiLock");
                iWifiLock.Acquire();
                iMulticastLock = iWifiManager.CreateMulticastLock("myMcastlock");
                iMulticastLock.Acquire();
            }

            iHelper = new Helper(new string[0] {
            });
            OptionPageCrashDumper optionCrashDumper = new OptionPageCrashDumper("Crash Logs");

            iHelper.AddOptionPage(optionCrashDumper);
            iWifiListener = new WifiListener(this, iHelper);
            iWifiListener.Refresh(this.ApplicationContext);

            iHelper.ProcessOptionsFileAndCommandLine();
            iHelper.Stack.SetStack(this);
            iCrashLogDumper = new CrashDumper(this.ApplicationContext, Resource.Drawable.Icon, iHelper, optionCrashDumper);
            iHelper.AddCrashLogDumper(iCrashLogDumper);
            iEventServer    = new EventServerUpnp();
            iListenerNotify = new SsdpListenerMulticast();

            iHouse = new House(iListenerNotify, iEventServer, new ModelFactory());
            iHouse.EventRoomAdded   += RoomAdded;
            iHouse.EventRoomRemoved += RoomRemoved;

            iLibrary = new Library(iListenerNotify);
            iLibrary.EventMediaServerAdded   += LibraryAdded;
            iLibrary.EventMediaServerRemoved += LibraryRemoved;

            iRescanTimer          = new System.Timers.Timer(kRescanTimeoutMilliseconds);
            iRescanTimer.Elapsed += (d, e) =>
            {
                if (iHelper.Stack.Status.State == EStackState.eOk)
                {
                    try
                    {
                        if (iHouse != null)
                        {
                            iHouse.Rescan();
                        }

                        if (iLibrary != null)
                        {
                            iLibrary.Rescan();
                        }
                    }
                    catch (Exception ex)
                    {
                        UserLog.WriteLine("Error caught on rescan: " + ex);
                    }
                }
            };

            iHelper.Stack.Start();
        }
Exemplo n.º 2
0
        private void InitialiseStack()
        {
            iEventCreated.WaitOne();
            iEventLock       = new object();
            iUserLogListener = new AndroidUserLogListener();
            UserLog.AddListener(iUserLogListener);
            iTraceListener = new AndroidTraceListener();
            Trace.AddListener(iTraceListener);
            iInvoker         = new Invoker(this.ApplicationContext);
            iResourceManager = new AndroidResourceManager(this.Resources);
            iIconResolver    = new IconResolver(iResourceManager);
            iLayoutInflater  = (LayoutInflater)GetSystemService(Context.LayoutInflaterService);

            iHelperKinsky = new HelperKinsky(new string[2] {
                "-t", kTraceLevel
            }, Invoker);
            Android.Runtime.AndroidEnvironment.UnhandledExceptionRaiser += UnhandledExceptionRaiser;

            // name the crash dumper section general and add other UI options
            OptionPageCrashDumper generalOptions = new OptionPageCrashDumper("General");

            iOptionExtendedTrackInfo = new OptionBool("trackinfo", "Extended track info", "Show extended track information for the current track", true);
            generalOptions.Add(iOptionExtendedTrackInfo);
            iOptionEnableRocker = new OptionBool("rocker", "Button controls", "Enable button controls for controlling volume and seeking", false);
            generalOptions.Add(iOptionEnableRocker);
            iOptionGroupTracks = new OptionBool("groupplaylist", "Group playlist tracks", "Grouping tracks by album within the playlist window", true);
            generalOptions.Add(iOptionGroupTracks);

            iOptionAutoLock = new OptionEnum("autolock", "Prevent auto-lock", "When to prevent auto-lock");
            iOptionAutoLock.AddDefault(kAutoLockNever);
            iOptionAutoLock.Add(kAutoLockCharging);
            iOptionAutoLock.Add(kAutoLockAlways);
            generalOptions.Add(iOptionAutoLock);
            iOptionAutoLock.EventValueChanged += OptionAutoLock_EventValueChangedHandler;
            iHelperKinsky.AddOptionPage(generalOptions);

            iHelperKinsky.SetStackExtender(this);
            iCrashLogDumper = new CrashDumper(this.ApplicationContext, Resource.Drawable.Icon, iHelperKinsky, generalOptions);
            iHelperKinsky.AddCrashLogDumper(iCrashLogDumper);

            iOptionInsertMode = new OptionInsertMode();
            iHelperKinsky.AddOption(iOptionInsertMode);

            iViewMaster = new ViewMaster();
            iHttpServer = new HttpServer(HttpServer.kPortKinskyDroid);
            iHttpClient = new HttpClient();

            iLibrary         = new MediaProviderLibrary(iHelperKinsky);
            iSharedPlaylists = new SharedPlaylists(iHelperKinsky);
            iLocalPlaylists  = new LocalPlaylists(iHelperKinsky, false);

            PluginManager pluginManager = new PluginManager(iHelperKinsky, iHttpClient, new MediaProviderSupport(iHttpServer));

            iLocator = new ContentDirectoryLocator(pluginManager, new AppRestartHandler());

            OptionBool optionSharedPlaylists = iLocator.Add(SharedPlaylists.kRootId, iSharedPlaylists);
            OptionBool optionLocalPlaylists  = iLocator.Add(LocalPlaylists.kRootId, iLocalPlaylists);

            iLocator.Add(MediaProviderLibrary.kLibraryId, iLibrary);
            iHelperKinsky.AddOptionPage(iLocator.OptionPage);

            iSaveSupport = new SaveSupport(iHelperKinsky, iSharedPlaylists, optionSharedPlaylists, iLocalPlaylists, optionLocalPlaylists);
            iPlaySupport = new PlaySupport();
            iHelperKinsky.ProcessOptionsFileAndCommandLine();

            Linn.Kinsky.Model model = new Linn.Kinsky.Model(iViewMaster, iPlaySupport);
            iMediator = new Mediator(iHelperKinsky, model);

            iAndroidViewMaster = new AndroidViewMaster(this,
                                                       iViewMaster,
                                                       iInvoker,
                                                       iResourceManager,
                                                       iSaveSupport,
                                                       iIconResolver,
                                                       iOptionGroupTracks,
                                                       iOptionExtendedTrackInfo,
                                                       IsTabletView ? kMaxImageCacheSizeTablet : kMaxImageCacheSizePhone);

            iStackWatchdog = new System.Threading.Timer(StackWatchdogExpired);
            iPowerListener = new PowerStateListener(this.ApplicationContext);
            iPowerListener.EventPowerStateChanged += EventPowerStateChangedHandler;

            iIsCharging  = PowerStateListener.IsConnected(this.ApplicationContext);
            iRescanTimer = new System.Threading.Timer((e) =>
            {
                Rescan();
            });
            iRescanTimer.Change(Timeout.Infinite, Timeout.Infinite);
            SetAutoLock();
            EventLowMemory += EventLowMemoryHandler;
            iInitialised    = true;
            StartStack();
        }