/*
         * Example activity element in array, notice each entry has profile info as well as "sport" on case RUN and cycling should be sepearte
         *
         * {
         *  id_str: '1234567890',
         *  id: 1234567890,
         *  profileId: 1234567890,
         *  profile: {
         *    id: 1234567890,
         *    publicId: '1234567890-1234567890-1234567890',
         *    firstName: 'Example',
         *    lastName: 'Name',
         *    male: true,
         *    imageSrc: 'https://static-cdn.zwift.com/prod/profile/12345678901234567890',
         *    imageSrcLarge: 'https://static-cdn.zwift.com/prod/profile/12345678901234567890',
         *    playerType: 'NORMAL',
         *    countryAlpha3: 'deu',
         *    countryCode: 276,
         *    useMetric: true,
         *    riding: false,
         *    privacy: [Object],
         *    socialFacts: null,
         *    worldId: null,
         *    enrolledZwiftAcademy: false,
         *    playerTypeId: 1,
         *    playerSubTypeId: null,
         *    currentActivityId: null
         *  },
         *  worldId: 1,
         *  name: 'Zwift Run - Watopia',
         *  description: null,
         *  privateActivity: true,
         *  sport: 'RUNNING',
         *  startDate: '2021-01-01T00:00:00.000+0000',
         *  endDate: '2021-01-01T01:00:00.00+0000',
         *  lastSaveDate: '2021-01-01T01:00:00.00+0000',
         *  autoClosed: false,
         *  duration: '1:00',
         *  distanceInMeters: 1234.56,
         *  fitFileBucket: 's3-fit-prd-uswest2-zwift',
         *  fitFileKey: 'prod/123456/123456-123456123456',
         *  totalElevation: 0,
         *  avgWatts: 0,
         *  rideOnGiven: false,
         *  activityRideOnCount: 42,
         *  activityCommentCount: 0,
         *  snapshotList: null,
         *  calories: 4242.00,
         *  primaryImageUrl: 'https://s3-fit-prd-uswest2-zwift.s3.amazonaws.com/prod/img/123456-123456123456123456',
         *  movingTimeInMs: 123456,
         *  privacy: 'PRIVATE',
         *  topNotableMoment: {
         *    notableMomentTypeId: 1,
         *    activityId: 123456123456123456123456,
         *    incidentTime: 123456,
         *    priority: 8,
         *    aux1: '3',
         *    aux2: '300'
         *  },
         *  avgSpeedInMetersPerSecond: 2.42,
         *  feedImageThumbnailUrl: 'https://s3-fit-prd-uswest2-zwift.s3.amazonaws.com/prod/img/1234561-23456123456123456',
         *  eventSubgroupId: null,
         *  eventId: null,
         *  clubActivity: false
         * },
         *
         */

        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);
            Name = api.GetMeasureName();
            Skin = api.GetSkin();

            user      = api.ReadString("zwiftUser", "");
            password  = api.ReadString("zwiftPass", "");
            pastMonth = api.ReadInt("pastMonth", 0);

            var feedArr = fetchZwiftFeed();

            try
            {
                foreach (var activity in feedArr)
                {
                    CultureInfo provider = CultureInfo.InvariantCulture;
                    DateTime    start    = DateTime.Parse(activity.startDate);
                    var         month    = new DateTime(start.Year, start.Month, 1);
                    if (!distanceDict.ContainsKey(month))
                    {
                        distanceDict[month] = 0;
                    }
                    distanceDict[month] += Convert.ToDouble(activity.distanceInMeters);
                }
            }
            catch (Exception e)
            {
                api.Log(API.LogType.Error, "ZWIFT_RM_API.dll: Reload error:" + e.Message);
            };
        }
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            Name = api.GetMeasureName();
            API.Log(API.LogType.Debug, "Mediamonkey.dll: Reloading ChildMeasure=" + Name);

            base.Reload(api, ref maxValue);

            string parentName = api.ReadString("PlayerName", "", false).Replace("[", "").Replace("]", "");
            IntPtr skin       = api.GetSkin();

            API.Log(API.LogType.Debug, "Mediamonkey.dll: Looking for ParentMeasure" + parentName + "in skin " + skin + "for ChildMeasure " + Name);

            // Find parent using name AND the skin handle to be sure that it's the right one.
            ParentMeasure = null;
            foreach (ParentMeasure parentMeasure in ParentMeasure.ParentMeasures)
            {
                if (parentMeasure.Skin.Equals(skin) && parentMeasure.Name.Equals(parentName))
                {
                    API.Log(API.LogType.Debug, "Mediamonkey.dll: Found ParentMeasure " + parentMeasure.Name + " for ChildMeasure " + Name);
                    ParentMeasure = parentMeasure;
                }
            }

            if (ParentMeasure == null)
            {
                API.Log(API.LogType.Error, "Mediamonkey.dll: PlayerName=" + parentName + " not valid");
            }
        }
Ejemplo n.º 3
0
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            string parentName = api.ReadString("ParentName", "");
            IntPtr skin       = api.GetSkin();

            // Find parent using name AND the skin handle to be sure that it's the right one
            RuntimeTypeHandle parentType = typeof(ParentMeasure).TypeHandle;

            foreach (KeyValuePair <uint, Measure> pair in Plugin.Measures)
            {
                if (System.Type.GetTypeHandle(pair.Value).Equals(parentType))
                {
                    ParentMeasure parentMeasure = (ParentMeasure)pair.Value;
                    if (parentMeasure.Name.Equals(parentName) &&
                        parentMeasure.Skin.Equals(skin))
                    {
                        HasParent = true;
                        ParentID  = pair.Key;
                        return;
                    }
                }
            }

            HasParent = false;
            API.Log(API.LogType.Error, "ParentChild.dll: ParentName=" + parentName + " not valid");
        }
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            Name = api.GetMeasureName();
            Skin = api.GetSkin();

            this.HistoryJsonPath = api.ReadString("HistoryJsonPath", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Netease/CloudMusic/webdata/file/history"));
        }
Ejemplo n.º 5
0
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            Name = api.GetMeasureName();
            Skin = api.GetSkin();

            Path   = api.ReadString("Path", "");
            Server = api.ReadString("Server", "");
        }
Ejemplo n.º 6
0
        //Set and Write Variable to ini File
        internal void SetVariable(string KeyName, string Value, IntPtr rm)
        {
            WritePrivateProfileString("Variables", KeyName, Value, Measure.iniPath);

            Rainmeter.API api     = (Rainmeter.API)rm;
            string        Command = string.Concat("[!SetVariable ", KeyName, " \"", Value, "\"]");

            API.Execute(api.GetSkin(), Command);
            return;
        }
Ejemplo n.º 7
0
        public void Setup(Rainmeter.API api)
        {
            // Init members
            SendAsync             = (api.ReadInt("SendAsync", 0) > 0);
            TryToReconnect        = false;
            KeepConnectionAlive   = (api.ReadInt("KeepAlive", 1) > 0);
            PingServer            = (api.ReadInt("PingServer", 0) > 0);
            MaxReconnectAttempts  = api.ReadInt("MaxReconnectAttempts", 0);
            CurrentAttempt        = 0;
            LastConnectionAttempt = DateTime.Now;
            LastPing = LastConnectionAttempt;

            // Setup WebSocket
            String Address = api.ReadString("Address", "");

            if (!Address.IsNullOrEmpty())
            {
                ws            = new WebSocket(Address);
                ws.NoDelay    = true;
                ws.OnOpen    += OnOpen;
                ws.OnMessage += OnMessage;
                ws.OnError   += OnError;
                ws.OnClose   += OnClose;
                ws.ConnectAsync();
            }

            // Get Commands
            Skin         = api.GetSkin();
            cmdOnOpen    = api.ReadString("OnOpen", "");
            cmdOnMessage = api.ReadString("OnMessage", "");
            cmdOnError   = api.ReadString("OnError", "");
            cmdOnClose   = api.ReadString("OnClose", "");

            // Get Parsable Commands

            // Ex: ParseCommands="AA:|BB:|CMD:"
            // OnAA:=[Some Bang]
            // OnBB:=[Some Bang]
            // OnCMD:=[Some Bang]

            Commands = new List <Command>();
            String cmds = api.ReadString("ParseCommands", "");

            if (!cmds.IsNullOrEmpty())
            {
                var tags = cmds.Split('|');
                foreach (var tag in tags)
                {
                    String c = api.ReadString("On" + tag, "");
                    Commands.Add(new Command {
                        Tag = tag, cmdOnTag = c
                    });
                }
            }
        }
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            Name = api.GetMeasureName();
            Skin = api.GetSkin();

            ValueA = api.ReadInt("ValueA", 0);
            ValueB = api.ReadInt("ValueB", 0);
            ValueC = api.ReadInt("ValueC", 0);
        }
Ejemplo n.º 9
0
        internal void Reload(Rainmeter.API rm, ref double maxValue)
        {
            SkinHandle     = rm.GetSkin();
            FinishAction   = rm.ReadString("FinishAction", "");
            ConnectionType = rm.ReadString("ConnectionType", "INTERNET").ToUpperInvariant();
            if (ConnectionType != "NETWORK" && ConnectionType != "INTERNET")
            {
                API.Log(API.LogType.Error, "CheckNet.dll: ConnectionType=" + ConnectionType + " not valid");
            }

            UpdateRate = rm.ReadInt("UpdateRate", 20);
            if (UpdateRate <= 0)
            {
                UpdateRate = 20;
            }
        }
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            Name = api.GetMeasureName();
            Skin = api.GetSkin();

            string DisableLeadingZeroString = api.ReadString("DisableLeadingZero", "false");

            if (DisableLeadingZeroString == "1")
            {
                DisableLeadingZero = true;
            }
            else if (DisableLeadingZeroString == "0")
            {
                DisableLeadingZero = false;
            }
            else
            {
                API.Log(API.LogType.Error, "MediaMonkey.dll: Invalid parameter for DisableLeadingZero =" + DisableLeadingZeroString);
            }
        }
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            string parentName = api.ReadString("ParentName", "");
            IntPtr skin       = api.GetSkin();

            // Find parent using name AND the skin handle to be sure that it's the right one.
            ParentMeasure = null;
            foreach (ParentMeasure parentMeasure in ParentMeasure.ParentMeasures)
            {
                if (parentMeasure.Skin.Equals(skin) && parentMeasure.Name.Equals(parentName))
                {
                    ParentMeasure = parentMeasure;
                }
            }

            if (ParentMeasure == null)
            {
                api.Log(API.LogType.Error, "ParentChild.dll: ParentName=" + parentName + " not valid");
            }
        }
Ejemplo n.º 12
0
 internal void Reload(Rainmeter.API api, ref double maxValue)
 {
     SkinHandle = api.GetSkin();
     if (teamspeakConnection.Connected == TeamspeakConnectionThread.ConnectionState.Disconnected)
     {
         if (teamspeakConnection.ConnectionThread == null || teamspeakConnection.ConnectionThread.ThreadState == ThreadState.Stopped)
         {
             if (!retryTimer.Enabled)
             {
                 retryTimer.Start();
                 API.Log(API.LogType.Debug, "Teamspeak.ddl: Retry timer started");
             }
         }
         else
         {
             API.Log(API.LogType.Debug, "Teamspeak.ddl: Reload, ConnectionThread is running");
         }
     }
     else
     {
         API.Log(API.LogType.Debug, "Teamspeak.ddl: Reload, ConnectionThread is running and connected");
     }
 }
Ejemplo n.º 13
0
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            Rainmeter = api;
            base.Reload(api, ref maxValue);

            Topic    = api.ReadString("Topic", "defaulttopic");
            Property = api.ReadString("Property", "");
            var qos = api.ReadInt("Qos", 0);

            ParentName = api.ReadString("ParentName", "");
            Skin       = api.GetSkin();

            // Find parent using name AND the skin handle to be sure that it's the right one.
            ParentMeasure = null;
            foreach (MqttClientMeasure parentMeasure in MqttClientMeasure.ParentMeasures)
            {
                if (parentMeasure.Skin.Equals(Skin) && parentMeasure.Name.Equals(ParentName))
                {
                    ParentMeasure = parentMeasure;
                    try
                    {
                        DebugLevel = parentMeasure.DebugLevel;
                        ParentMeasure.Subscribe(Topic, (byte)qos);
                    }
                    catch
                    {
                        Debug("Error Subscribing !", 1);
                    }
                }
            }

            if (ParentMeasure == null)
            {
                Log(API.LogType.Error, "ParentChild.dll: ParentName=" + ParentName + " not valid");
            }
        }
Ejemplo n.º 14
0
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            string parentName = api.ReadString(PARAM_PARENT_NAME, "");

            IntPtr skin = api.GetSkin();

            property = api.ReadString(PARAM_PROPERTY, "");


            String mesureName = api.GetMeasureName();

            if (mesureName.StartsWith(parentName))
            {
                String sndx = mesureName.Substring(parentName.Length);
                if (sndx.IndexOf("_") > 0)
                {
                    if (String.IsNullOrEmpty(property))
                    {
                        property = sndx.Substring(sndx.IndexOf("_") + 1);
                    }

                    sndx = sndx.Substring(0, sndx.IndexOf("_"));
                }

                ndx = int.Parse(sndx);
            }
            else
            {
                ndx = api.ReadInt(PARAM_INDEX, 1);
            }

            ndx--;


            // Find parent using name AND the skin handle to be sure that it's the right one
            RuntimeTypeHandle parentType = typeof(ParentMeasure).TypeHandle;

            foreach (KeyValuePair <uint, Measure> pair in Plugin.Measures)
            {
                if (System.Type.GetTypeHandle(pair.Value).Equals(parentType))
                {
                    ParentMeasure parentMeasure = (ParentMeasure)pair.Value;

                    if (parentMeasure.Name.Equals(parentName) &&
                        parentMeasure.Skin.Equals(skin))
                    {
                        HasParent = true;
                        ParentID  = pair.Key;

                        todayDateFormat = api.ReadString(ParentMeasure.PARAM_TODAY_FORMAT, parentMeasure.todayDateFormat);
                        weekDateFormat  = api.ReadString(ParentMeasure.PARAM_WEEK_DATE_FORMAT, parentMeasure.weekDateFormat);
                        dateFormat      = api.ReadString(ParentMeasure.PARAM_DATE_FORMAT, parentMeasure.dateFormat);

                        return;
                    }
                }
            }

            HasParent = false;
            API.Log(API.LogType.Error, "RainGoo.dll: ParentName=" + parentName + " not valid");
        }
Ejemplo n.º 15
0
        internal virtual void Reload(Rainmeter.API api, ref double maxValue)
        {
            //@TODO Use this port
            int port = api.ReadInt("Port", 58932);

            myService = api.ReadString("Name", "");
            //If my service does not start with a slash
            if (myService.Substring(0, 1) != "/")
            {
                myService = "/" + myService;
            }

            string newCommandOnOpen    = api.ReadString("OnOpen", "");
            string newCommandOnClose   = api.ReadString("OnClose", "");
            string newCommandOnMessage = api.ReadString("OnMessage", "");

            mySkin = api.GetSkin();
            string myMeasure = api.GetMeasureName();

            bool isNewService = true;
            int  serviceLoc   = 0;

            foreach (string service in services)
            {
                //If new service already exists
                if (myService == service)
                {
                    isNewService = false;
                    bool isNewSkin = true;
                    myServiceID = serviceLoc;

                    //Check if a skin with the same ID already exists if it does then just update instead of making a new skin
                    //Note: we just compare against onOpen, so make sure it is safe to assume they are always in the same loc from same skin @TODO Actually lets just merge execute command to have an open and a close command Edit: Mostly done
                    foreach (ExecuteCommand command in commands[serviceLoc])
                    {
                        //Check if from the same skin
                        if (command.Skin == mySkin)
                        {
                            //Check if from the same measure (No one really should be using two measures in the same service but since I did it for testing I might as well check for it as well)
                            if (command.Measure == myMeasure)
                            {
                                isNewSkin                = false;
                                command.CommandOnOpen    = newCommandOnOpen;
                                command.CommandOnClose   = newCommandOnClose;
                                command.CommandOnMessage = newCommandOnMessage;
                            }
                        }
                    }

                    if (isNewSkin)
                    {
                        commands[serviceLoc].Add(new ExecuteCommand(mySkin, myMeasure, newCommandOnOpen, newCommandOnClose, newCommandOnMessage));
                    }
                }
                serviceLoc++;
            }

            //If new service is actually new service
            if (isNewService)
            {
                services.Add(myService);

                //Add a new item in the top level (Services) of the list that contains a list of one command
                commands.Add(new List <ExecuteCommand>(new ExecuteCommand[] { new ExecuteCommand(mySkin, myMeasure, newCommandOnOpen, newCommandOnClose, newCommandOnMessage) }));

                //Start new service
                wssv.AddWebSocketService <MessagePassing>(myService);
            }
        }
Ejemplo n.º 16
0
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            Name = api.GetMeasureName();
            //API.Log(API.LogType.Notice, "RainGoo.dll : Measure name is  : " + Name);

            googleClientId     = api.ReadString(PARAM_GOOGLE_CLIENT_ID, "");
            googleClientSecret = api.ReadString(PARAM_GOOGLE_CLIENT_SECRET, "");
            googleAppName      = api.ReadString(PARAM_GOOGLE_APP_NAME, "");
            googleUserName     = api.ReadString(PARAM_GOOGLE_USER_NAME, "");



            if (Name == "mGcal")
            {
                Skin = api.GetSkin();

                calUrls.Clear();

                int    i   = 1;
                String tmp = null;

                while (!String.IsNullOrWhiteSpace((tmp = api.ReadString(PARAM_CAL + i, ""))))
                {
                    if (tmp != "#Calendar2#" && tmp != "#Calendar3#")
                    {
                        calUrls.Add(tmp);
                    }
                    i++;
                }

                max          = api.ReadInt(PARAM_MAX, DEFAULT_MAX);
                Limit2Xdays  = api.ReadInt(PARAM_LIMIT2XDAYS, DEFAULT_LIMITXDAYS);
                MIN_INTERVAL = api.ReadInt(PARAM_REFRESH_CAL, 30) * 1000;


                todayDateFormat = api.ReadString(PARAM_TODAY_FORMAT, "HH:mm");
                weekDateFormat  = api.ReadString(PARAM_WEEK_DATE_FORMAT, "ddd");
                dateFormat      = api.ReadString(PARAM_DATE_FORMAT, "ddd dd MMM");



#if DEBUG
                API.Log(API.LogType.Notice, "RainGoo.dll: Calendars : " + calUrls.Count + " - Max results : " + max + " - Limit 2 X days : " + Limit2Xdays);
#endif

                calendarPath = api.ReadPath(PARAM_INC_PATH, "");

                lastUpdate = 0;
                UpdateEvents();
            }
            else
            {
                Skin = api.GetSkin();
                // Generates include files
                maxGmail  = api.ReadInt(PARAM_MAX, DEFAULT_MAX);
                gmailPath = api.ReadPath(PARAM_INC_PATH, "");
#if DEBUG
                API.Log(API.LogType.Notice, "RainGoo.dll: Gmail inc file path :" + gmailPath);
#endif
                lastUpdategmail   = 0;
                MIN_INTERVALGMAIL = api.ReadInt(PARAM_REFRESH_MAIL, 10) * 1000;
                UpdateGmail();
            }
        }
Ejemplo n.º 17
0
        internal MqttClientMeasure(Rainmeter.API api)
        {
            ParentMeasures.Add(this);
            ParentRainmeterApis.Add(api);
            this.Rainmeter = api;
            this.Name      = api.GetMeasureName();
            Skin           = api.GetSkin();
            DebugLevel     = (ushort)api.ReadInt("DebugLevel", 0);

            Server        = api.ReadString("Server", "localhost");
            Port          = (ushort)api.ReadInt("Port", 1883);
            RetryInterval = (ushort)api.ReadDouble("RetryInterval", 5.0);
            ClientId      = api.ReadString("ClientId", Guid.NewGuid().ToString());
            Username      = api.ReadString("Username", "");
            Password      = new SecureString();
            foreach (char ch in api.ReadString("Password", ""))
            {
                Password.AppendChar(ch);
            }

            /* Mqtt Server Bangs */
            OnConnectBangs    = SplitBangs(api.ReadString("OnConnect", ""));
            OnDisconnectBangs = SplitBangs(api.ReadString("OnConnect", ""));
            OnReloadBangs     = SplitBangs(api.ReadString("OnReload", ""));
            OnMessageBangs    = SplitBangs(api.ReadString("OnMessage", ""));

            MqttClient = Factory.CreateManagedMqttClient();

            /* Setup Event Handlers */
            MqttClient.UseConnectedHandler(e =>
            {
                if (!MqttClientMeasure.ParentRainmeterApis.Contains(Rainmeter))
                {
                    return;
                }

                Log(API.LogType.Notice, "Connected to " + Server + " : " + Port);

                if (OnConnectBangs.Length > 0)
                {
                    Log(API.LogType.Notice, "Executing OnConnect Bangs");
                    ExecuteBangs(OnConnectBangs);
                }
            });

            MqttClient.UseApplicationMessageReceivedHandler(e =>
            {
                if (!MqttClientMeasure.ParentRainmeterApis.Contains(Rainmeter))
                {
                    return;
                }

                e.GetType();
                String topic   = e.ApplicationMessage.Topic;
                String payload = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
                try
                {
                    Debug("### RECEIVED APPLICATION MESSAGE ###", 3);
                    Debug($" >> Topic = {e.ApplicationMessage.Topic}", 4);
                    Debug($" >> Payload = {Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}", 4);
                    Debug($" >> QoS = {e.ApplicationMessage.QualityOfServiceLevel}", 5);
                    Debug($" >> Retain = {e.ApplicationMessage.Retain}", 5);

                    if (Topics.Contains(topic))
                    {
                        Topics[topic] = payload;
                        Log(API.LogType.Notice, "Received update for " + topic);
                    }
                    else
                    {
                        Topics.Add(topic, payload);
                        Log(API.LogType.Warning, "Received payload for unknown topic " + topic);
                    }

                    if (OnMessageBangs.Length > 0)
                    {
                        Log(API.LogType.Notice, "Executing OnMessage Bangs");
                        ExecuteBangs(OnMessageBangs);
                    }
                }
                catch
                {
                    // Error Application
                }
            });

            MqttClient.UseDisconnectedHandler(e =>
            {
                if (!MqttClientMeasure.ParentRainmeterApis.Contains(Rainmeter))
                {
                    return;
                }

                Log(API.LogType.Error, e.Exception?.Message);
                Log(API.LogType.Error, e.AuthenticateResult?.ReasonString);
                Log(API.LogType.Error, e.ClientWasConnected.ToString());

                if (!MqttClient.IsConnected)
                {
                    Log(API.LogType.Warning, "Lost previous connection to " + Server + " : " + Port);
                }

                if (OnDisconnectBangs.Length > 0)
                {
                    Log(API.LogType.Notice, "Executing OnDisconnect Bangs");
                    ExecuteBangs(OnDisconnectBangs);
                }
            });

            try
            {
                Log(API.LogType.Warning, "Connecting to " + Server + " : " + Port + "...");
                ConnectAsync(Server, Port, Username, Password, ClientId).Wait();
            }
            catch (Exception ex)
            {
                Log(API.LogType.Error, "Exception trying to connect: " + ex);
                return;
            }
        }