It is currently September 20th, 2020, 8:31 pm

Plugin file write to location best practices.

Share and get help with Plugins and Addons
User avatar
tjhrulz
Developer
Posts: 252
Joined: October 13th, 2016, 1:28 am
Location: Earth

Plugin file write to location best practices.

Post by tjhrulz »

So I am currently writing a plugin that opens a websocket sends a temporary authorization code and gets a permanent authorization code. This code is specific to the machine so I don't need to worry about obfuscating it and would like to store it in a way so that once the plugin has gotten the auth code once all future loads can just use the permanent auth code. I can just simply store it in a file but I am not sure where the best place to store it would be. I first thought that storing it under ~\Documents\Rainmeter\ would be best but the user does not necessarily have to have their skins there, would storing it in ~\AppData\Roaming\Rainmeter\ be a better location/what would be the accepted practice for doing something like this?
User avatar
Brian
Developer
Posts: 2061
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Plugin file write to location best practices.

Post by Brian »

I would recommend storing it in the Rainmeter data file. You can get this by calling RmGetSettingsFile.
https://github.com/rainmeter/rainmeter-plugin-sdk/wiki/C---plugin-API

There can be other data stored there from Rainmeter itself or other plugins, so be careful not to delete the file. I would recommend using GetPrivateProfileString to get the data from the file and WritePrivateProfileString to retrieve it.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724353(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ms725501(v=vs.85).aspx

-Brian
User avatar
tjhrulz
Developer
Posts: 252
Joined: October 13th, 2016, 1:28 am
Location: Earth

Re: Plugin file write to location best practices.

Post by tjhrulz »

Thanks I had assumed that that returned a link to the Rainmeter settings file not a file to be used for plugin settings. Also I'll make sure I use those methods.

Also just wanted to say that in your examples and documentation, unless if I overlooked it which is entirely possible, that there is not any references on how to handle bangs. I figured it out looking at the source code of someone else's rainmeter plugin but just figured I would mention that.
User avatar
Brian
Developer
Posts: 2061
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Plugin file write to location best practices.

Post by Brian »

tjhrulz wrote:...that there is not any references on how to handle bangs.
ExecuteBang and RmExecute are both in the plugin docs.
https://github.com/rainmeter/rainmeter-plugin-sdk/wiki/C---plugin-API

There are also 3 examples (both for C++ and C#).
C++ examples: https://github.com/rainmeter/rainmeter-plugin-sdk/tree/master/C%2B%2B
C# examples: https://github.com/rainmeter/rainmeter-plugin-sdk/tree/master/C%23

Rainmeter plugins: https://github.com/rainmeter/rainmeter/tree/master/Plugins
Our SendMessage interface (for external applications): https://docs.rainmeter.net/developers/#SendMessage

Not to mention various other plugin examples on github. Here are mine: https://github.com/brianferguson?tab=repositories

Here are some more 3rd-party sources:
https://github.com/TheAzack9?tab=repositories
https://github.com/dcgrace?tab=repositories
https://github.com/cfixd?tab=repositories
https://github.com/socks-the-fox/Chameleon

While our plugin documentation does need some work, the amount of documentation and examples in the links above should provide a good example of how our SDK works.

-Brian
User avatar
tjhrulz
Developer
Posts: 252
Joined: October 13th, 2016, 1:28 am
Location: Earth

Re: Plugin file write to location best practices.

Post by tjhrulz »

Sorry I should have been more clear I was specifically referring to the C# documentation lacking any mention of ExecuteBang. But yeah I just used community examples to figure it out.

Not a big deal to me personally but someone with less programming experience they are not as friendly as the rest of rainmeters documentation. But then again writing a plugin is not as friendly as writing a rainmeter skin. :p

Thanks for your time Brian.
User avatar
jsmorley
Developer
Posts: 21372
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Plugin file write to location best practices.

Post by jsmorley »

Our plugin SDK docs really are kinda sad. I think the thing we need to do is decide on the "target audience" for it. I think right now it is, to be as generous as possible, targeted at experienced, skilled C++ / C# developers. it is "terse" to the point of "hostile". I personally don't think that is right. Our goal should be to encourage plugin development.

While much like our Lua documentation, I don't think we should be in the business of teaching C++ to anyone, I think we can assume that pretty much anyone that can "program" is capable of using google and finding just tons of help for the part of the code that is specific to what they are trying to do.

As to the "internal" Rainmeter part of the functionality, I really think it should be very complete, targeted at a "beginner", with good explanations and relevant examples.
User avatar
limitless
Posts: 59
Joined: January 8th, 2017, 2:31 am
Location: Charlotte, NC

Re: Plugin file write to location best practices.

Post by limitless »

jsmorley wrote:Our plugin SDK docs really are kinda sad. I think the thing we need to do is decide on the "target audience" for it. I think right now it is, to be as generous as possible, targeted at experienced, skilled C++ / C# developers. it is "terse" to the point of "hostile". I personally don't think that is right. Our goal should be to encourage plugin development.

While much like our Lua documentation, I don't think we should be in the business of teaching C++ to anyone, I think we can assume that pretty much anyone that can "program" is capable of using google and finding just tons of help for the part of the code that is specific to what they are trying to do.

As to the "internal" Rainmeter part of the functionality, I really think it should be very complete, targeted at a "beginner", with good explanations and relevant examples.
Well said! :thumbup:
Image