It’s 1:30 AM and I finally managed to have a working snippet…
It was so hard to use readf/readfi. For some reasons I had perfs errors with readfi so I rewrote everything with inits, I still don’t know what happened
<Cabbage>
form caption("Cabbage Security") size(400, 400), guiMode("queue") pluginId("def1")
label bounds(110, 98, 167, 18) channel("writtenresult") text("")
texteditor bounds(32, 308, 339, 50) fontSize(16), channel("orcText") fontColour(124, 210, 0), colour(0, 0, 0, 100), mode("single")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
SuserHome chnget "USER_HOME_DIRECTORY"
SFileName strcat SuserHome, "/Library/Application Support/Nymano Audio/test.txt"
Stext cabbageGetValue "orcText"
READ:
iOpen fiopen SFileName, 1
Sline, iLinNum readfi SFileName ; read
cabbageSet "writtenresult", "text", Sline
ficlose iOpen
rireturn
goto listener
WRITE:
iOpen fiopen SFileName, 0
if strlen(Stext)>0 then
fprints SFileName, Stext ; write
endif
ficlose iOpen
rireturn
listener:
if changed:k(Stext) == 1 then
reinit WRITE
reinit READ
reinit READ
endif
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 [60*60*24*7]
</CsScore>
</CsoundSynthesizer>
It is still a bit sketchy, but it looks like it’s working.
When the plugin loads, it reads a file called test.txt in a specific folder (my installer will place this file in the folder, I’m sure it exists). Then I will add a check “if the content == this condition then the plugin runs”.
If it’s not the case, the csound script goes to the “listener” part. When the user enters a new key, it is written in the file and the script re-reads the file again. I don’t know why I have to reinit it 2 times to make it work, it’s probably too late to figure it out
I just have to code the serial key check and I think it’s almost done. Do you think this is a correct solution to add a “weak protection” to the plugin and prevent copy/paste?
Julien