Miranda NG Official Community Forum

Forum for English speaking Miranda NG users => Support/Help => Topic started by: Testertime on 03 04 2016, 20:57:32

Title: How can I set permanent standard settings for new accounts?
Post by: Testertime on 03 04 2016, 20:57:32
Hey everyone! :)

I'm looking for a way to customize the Miranda NG settings in advance or to override standard settings in Miranda NG. It is about adding new Jabber accounts in Miranda NG. Usually when I'm sending an customized Miranda NG archive with many plugins to someone for a convenient quick start, and the person is adding a Jabber account to Miranda NG, there are still some settings which need to be adjusted. So far I haven't found a way to set them in advance. And the user shouldn't need to do this. I am mainly talking about removing the tick in advance from "Allow file sending through direct peer-to-peer connection transfers" (because it isn't working), and adding a ticket to "Send messages slower, but with full acknowledgment" (damn useful to prevent silent message loss). So far I have seen that I can pick some settings with the Database Editor++ plugin and using it to import settings for JABBER_1 again, so that these specific settings are automatically applied to the first existing Jabber account. But it still requires manual work, so my question is...

Is there a way to permanently set such account-specific settings in advance, especially for all new accounts?

Somewhere these settings are hardcoded in Miranda NG, and as Miranda NG is awesome, there is surely a way. ;D

Thanks a lot in advance!
Title: Re: How can I set permanent standard settings for new accounts?
Post by: AnrDaemon on 04 04 2016, 00:48:17
You can supply required settings in a tweak ini file loaded by the Miranda.
Title: Re: How can I set permanent standard settings for new accounts?
Post by: Robyer on 04 04 2016, 11:56:20
You can supply required settings in a tweak ini file loaded by the Miranda.
Except you can't possibly know what "internal name" the user will choose for their newly created account. And AFAIK there is no api for loading some ini file when new account is created.

I already mentioned usefulness of having "global protocol options" separated from "this protocol's account options" back in Miranda IM times, but it wasn't worth the time / interesting enough.

So, to answer the question:
Is there a way to permanently set such account-specific settings in advance, especially for all new accounts?
No, it's not possible right now.
Title: Re: How can I set permanent standard settings for new accounts?
Post by: AnrDaemon on 04 04 2016, 13:18:46
Oh, I misread the question then. Sorry.
Title: Re: How can I set permanent standard settings for new accounts?
Post by: Testertime on 12 05 2016, 19:52:37
Thanks for your answers! And sorry about the delay.

You can supply required settings in a tweak ini file loaded by the Miranda.

The info is a bit much limited, but I have seen what you are talking about (the mirandaboot.ini file). Luckily there are good descriptions included, so it is possible to do what I wanted to achieve. I'm showing the necessary steps to do the same (in my case for a Jabber account):

1. Download the Database Editor++ (http://wiki.miranda-ng.org/index.php?title=Plugin:DbEditorPP/en) and add the dll file to Miranda NGs "Plugins" folder.

2. Start up Miranda NG and click on the registry icon button called "Open Database editor". If the desired Jabber account doesn't exist already, create one now.

3. Extend the "Settings" entry and you will see an entry called "JABBER_1". The Jabber account settings are stored here. Right click it and click on "Export" and then save the ini file.

4. If you would like to apply all settings to a copy of Miranda NG, it's enough to rename the file to autoexec_forced_jabber.ini (name style has to be autoexec_forced_*.ini). Place this ini file into Mirandas main folder.
In my case, I have adjusted the file to include just these settings. The main benefit here is, that no account will show up, but these settings are applied to a new one anyway!

Spoiler
Code: [Select]
SETTINGS:

[JABBER_1]
BsDirectAddr=u
BsDirectManual=b0
BsDirect=b0
BsProxyManual=b0
MsgAck=b1
EnableAvatars=b1
LogChatstates=b0
LogPresence=b1
LogPresenceErrors=b0
EnableUserMood=b1
EnableUserTune=b0
EnableUserActivity=b1
AcceptNotes=b1
AutosaveNotes=b0
EnableMsgArchive=b0
Disable3920auth=b0
EnableZlib=b1
EnableRemoteControl=b0
ShowTransport=b1
AutoAdd=b1
AutoAcceptAuthorization=b0
FixIncorrectTimestamps=b1
DisableFrame=b1
ProcessXMPPLinks=b0
IgnoreRosterGroups=b0
AllowVersionRequests=b1
ShowOSVersion=b1
BsOnlyIBB=b0
AcceptHttpAuth=b1
[close]

5. Miranda NG is going to warn you about the changes. To avoid this warning, edit the mirandaboot.ini file and change the warn setting to "onlyunsafe". I don't know if this is a clever idea to change this, so keep in mind that it could be unsafe, if a harmful program places an ini file there.

6. Done. The settings are successfully applied. If you got trouble to find your desired setting in the database editor, there is a trick: Export all settings via the database editor, change your desired values, and then export the settings again. Now you can use a program like WinMerge to compare both text files.

I'm hoping this text is helpful to someone else and understandable.

So, to answer the question:No, it's not possible right now.

Okay, good to know that it isn't officially supported in an easy way. With my method it's actually working, but it's more like a workaround. Because if the user decides to delete the account in Miranda NG, and creates a new one, then these predefined settings are gone. Unless the ini settings file is applied at every start up, but that's not the most elegant way...
Title: Re: How can I set permanent standard settings for new accounts?
Post by: Robyer on 12 05 2016, 20:51:50
Testertime, also your solution doesn't count with situation, where user chooses different internal name for the new account (different than JABBER_1). Or that the user creates 2 accounts.
Title: Re: How can I set permanent standard settings for new accounts?
Post by: Testertime on 12 05 2016, 22:29:35
Testertime, also your solution doesn't count with situation, where user chooses different internal name for the new account (different than JABBER_1). Or that the user creates 2 accounts.

Oh! Thanks for this information. I just did some testing, and I have seen if I'm repeating the same steps, but the name is JABBER_2, then it seems to work as well. But yeah, still rather ... "risky". Hopefully there is a better way in the future.
Title: Re: How can I set permanent standard settings for new accounts?
Post by: wsx22 on 13 05 2016, 16:19:53
I did what You want with MirLua (with some workarounds :) )


Code: [Select]

local proto = require('m_protocols')
local db = require('m_database')

local hHook = m.HookEvent('Proto/AccListChanged', function(w, l)
-- Proto/AccListChanged
-- // wParam = event type (1 - added, 2 - changed, 3 - deleted, 4 - upgraded, 5 - enabled/disabled)
-- // lParam = (LPARAM)(PROTOACCOUNT*) - account being changed
print('Proto/AccListChanged is raised ' .. ' wParam = ' .. tostring(w) .. '   lParam = ' .. tostring(l)     )

-- dont know if it is possible to get tostring(l.szModuleName) from l ?
-- probably cannot beacouse it's not implemented in MirLua

-- only if event type == 1 - added
if tostring(w):sub(-1) == '1' then

-- Need to find last added account via db internals settings
-- You can modyfy this code to get accounts only from specified protocol via looking for AM_BaseProto setting
local accountInt = -1 --number
local accountIntValue --number
local maxValue = 0 --number
local maxValueProtoInt --number
local accountIntVar -- string
local lastAccountName -- string

repeat
accountInt = accountInt + 1

if accountInt >= 100 then
return
elseif accountInt >= 10 then
accountIntVar = string.format("2%d", accountInt)
else
accountIntVar = string.format("20%d", accountInt)
end

accountIntValue = db.GetSetting(nil, 'Protocols', accountIntVar, -1)
print('accountIntVar=' ..   tostring(accountIntVar) .. ' accountIntValue=' ..   tostring(accountIntValue)  )

if accountIntValue > -1 then
if accountIntValue > maxValue then
maxValue = accountIntValue
maxValueAccountInt = accountInt
end
end

until accountIntValue < 0
 
lastAccountName = db.GetSetting(nil, 'Protocols', tostring(maxValueAccountInt), 'null')
print('AFTER maxValueAccountInt=' ..   tostring(maxValueAccountInt) .. '  accountInt=' ..   tostring(accountInt) .. '  lastAccountName=' ..   tostring(lastAccountName) )

-- now You can save to db what You want :)
db.WriteSetting(nil, lastAccountName, 'MyNewSetting', 'MyNewSettingValue')
print('WROTE setting to last proto db branch'   )

end

end)