Picture of mitop
Registered 3 years 291 days
mitop Thursday, 12 August 2021, 12:15 PM
Customize PBX Manager Plugin
Hi everbody,

after getting the replicator running (https://class.innovaphone.com/moodle2/mod/forum/discuss.php?d=25440) we want to add the PBX Manager Plugin to our app.

"As many installations use several PBXes (master/slaves), this PBX name must be configurable inside your App, e.g. by a PBX Manager Plugin.", this is what we want to achieve, that was your hint in the last post from the link above.
What we need are two (or one) extra string data fields in the PBX Manager Plugin, where we can write down the domain/system Name and the PBX name, right? This information should be stored and loaded when the Ap_... starts and the Users App should get this value so that the replicator catches the database entries from the right PBX.
Is there a tutorial or discription for this (modifying the PBX manager plugin, store/load own values and update runnning/users app configuration)? If I'm not completely wrong now, we need the same functionality as the Users app (see attachment). Another question: How is this value initially set or determined? The Users app works after installation without any adjustments.

users_change_conf2.PNG

Picture of mitop
Registered 3 years 291 days
mitop Friday, 13 August 2021, 10:47 AM
Re: Customize PBX Manager Plugin
Hi again,

what i found here "http://class.innovaphone.com/moodle2/mod/forum/discuss.php?d=25360" posted on "Monday, 8 June 2020, 05:34 PM " - is this the way how to do it (ConfigContext, ConfigItem)? Or is there another prefered way?

Is there an code example how to do that? I apologize for bugging you about this, i try to get familiar with the SDK and all his posibilities. It is not yet easy for me to get used to the hole SDK functionality.
Picture of mitop
Registered 3 years 291 days
mitop Wednesday, 18 August 2021, 10:15 AM in response to mitop
Re: Customize PBX Manager Plugin
Hello,

i have made some progress on my own. The C++ side "ConfigContext" (https://sdk.innovaphone.com/13r1/web1/config/config.htm) works (and replicator still works too), config database was added and i can see my own values. As next step, i try to fetch these values on the Javascript side in the main js file of my app, simply by printing them out first. Once that works I will transfer the functionality to the pbx manager plugin.
But i get stucked, and i am running out of ideas. Please see code in the picture below, it seems that i cannot create the "Config" object inside Javascript. Do you have any idea what i´m missing??? Unfortunately, the sdk documentation does not give me any more information or i do not know where to look for.

no_config_on_javascript_side.PNG

Picture of Carmen Álvarez Méndez (innovaphone)
Moderator Registered 7 years 85 days
Carmen Álvarez Méndez (innovaphone) Friday, 20 August 2021, 10:56 AM
Re: Customize PBX Manager Plugin
Hi,

You need to consume the Devices API:
var devicesApi = start.consumeApi("com.innovaphone.devices");

Then you can use GetGateways to receive a list with all the available gateways:
var gateways = [];
var gnames = [];
var dd = null;
if (devicesApi && devicesApi.providers.length > 0) {
var src = new devicesApi.Src(apiresult);
var answers = devicesApi.providers.length;
src.send({ mt: "GetGateways" }, null);
function apiresult(obj) {
if (obj.msg.mt == "GetGatewaysResult") {
var ok = false;
if (obj.msg.gateways) {
for (var i = 0; i < obj.msg.gateways.length; i++) {
if (obj.msg.gateways[i].online) {
obj.msg.gateways[i].provider = obj.provider || provider;
gateways[gateways.length] = obj.msg.gateways[i];
}
}
}
 
}
}
}

Then you will have a list with all the gateways that you can add to your dropdown. In Users then it is checked which gateway name has already been configured as PBX-Name and preselects it on the dropdown.
Picture of mitop
Registered 3 years 291 days
mitop Monday, 23 August 2021, 02:25 PM
Re: Customize PBX Manager Plugin
Hi Carmen,

thank you for your reply. Your solution will help to give the user a better UI expirience (it seems to fit better as an answer to "http://class.innovaphone.com/moodle2/mod/forum/discuss.php?d=25360" Programmatically detection of connected PBX).
What i tried to achive was a string input field where the user can write down pbx name and domain. Now we have the option of a dropdown list, great.
Unfortunetly, my initial problem isn`t solved with this solution.

We have four points to achive:
a Store/Load Configuration option on C++ side
b Create/Modify the User interface for the app manager plugin
bb Dropdown, Textinput, etc.
c "Transfer" user input/selection from UI to C++ side so that it is updated, or in other words: Communication betwenn the pbx plugin manager UI and the C++ side?

The two problems that i am faced to:

1. How can i get the initial active pbx to use her name and domain as initial values? Most of our customers innovaphone system configuration has only one pbx and we want our app to fetch it automatically. What i found here "https://sdk.innovaphone.com/13r1/common/interface/pbx.htm" was the "CreateGetNodeInfo" function. Can i use this to get information from my current pbx and use these values for inital connection on C++ side? Or is something similar to com.innovaphone.devices available on C++ side?

2. How do i tell the C++ side, that on the Javascript side, a configuration option has changed? So that the C++ side can reload whatever with proper information. I found the "Config" Class, and managed to get the C++ side running (talble and values added to local db). But i can not create a Config Object on the Javascript side to access and modify these values. (see previous screenshot please)


In the short term, solution 1. is enough, load default active pbx configuration, because/assuming there is only one pbx in the system.
In the long run we would implement solution 2 (as soon as possible).


Kind regards,
Mladen
Picture of mitop
Registered 3 years 291 days
mitop Monday, 23 August 2021, 02:50 PM
Re: Customize PBX Manager Plugin
I missunderstood the "CreateGetNodeInfo" function, it needs the pbx name and domain too, like the replicator does. So this is not the way to get current pbx values on C++ side. Sorry, my error
Picture of mitop
Registered 3 years 291 days
mitop Monday, 23 August 2021, 03:35 PM in response to mitop
Re: Customize PBX Manager Plugin
I got the Config Object running on Javascript Side. I added "include sdk/web1/config/config.mak" to the main App mak file and this line "<script src="web/config/innovaphone.config.js" type="text/javascript"></script>" to the apps\company-appname.htm file and the Object has been created on Javascript side.
Just now i see, that there is no mak file for the company.appnamemanager Plugin. Does the pbx manager plugin use the main mak file???

An answer to this would be great:
1. How can i get the initial active pbx to use her name and domain as initial values? Most of our customers innovaphone system configuration has only one pbx and we want our app to fetch it automatically. Is there something similar to com.innovaphone.devices available on C++ side?


Picture of Carmen Álvarez Méndez (innovaphone)
Moderator Registered 7 years 85 days
Carmen Álvarez Méndez (innovaphone) Monday, 23 August 2021, 04:47 PM
Re: Customize PBX Manager Plugin
There must always be a function on the App Service similar to this one:
void UsersService::AppInstancePlugins(istd::list<AppInstancePlugin>* pluginList)
{
pluginList->push_back(new AppInstancePlugin("innovaphone.ManagerUsers", "innovaphone-users.png", "innovaphone.ManagerUsersTexts", false));
}

With this function the AP Manager knows that that App Service provides also a Plugin.

To get config items on the Javascript side you can start another App Websocket connection with your app and if you are using the Config Library, do something like this:
usersWS = new innovaphone.appwebsocket.Connection(usersURL.replace("http", "ws"), "-", null, app.domain, usersConnected, usersMessage, null, null, usersLogin);
function usersLogin(app, challenge) {
var srcus = new managerApi.Src(getlogin);
srcus.send({ mt: "GetInstanceLogin", path: item.apUri.slice(0, item.apUri.lastIndexOf("/")), app: app, challenge: challenge }, item.ap);
function getlogin(obj) {
usersWS.login(obj.msg);
srcus.close();
}
}

function usersConnected() { usersWS.send({ api: "Config", mt: "ReadConfig" }); }

function usersMessage(msg) {
if (msg.mt == "ReadConfigResult") {
// Example with the Users Config Items
allowDelete = msg.ConfigItems.allowDelete;
pbxReplicator = msg.ConfigItems.pbxName;
changeConfig();
usersWS.close();
}
}

If there is only one PBX, with GetGateways you should only receive one PBX. Otherwise there is no magic way to guess which one do you want to connect to because it could really be any of them. On Users we resolve this by inserting the PBX-Name on the config tab, which is preconfigured by the installer.

If you want to use the Devices API from the C++ side, you should use the Services Protocol:
https://sdk.innovaphone.com/13r2/doc/appwebsocket/Services.htm
Picture of mitop
Registered 3 years 291 days
mitop Tuesday, 24 August 2021, 11:25 AM
Re: Customize PBX Manager Plugin
"To get config items on the Javascript side..." - i will try your code.
But I don't want to give up yet and would much rather get the config class running on Javascript side (https://sdk.innovaphone.com/13r1/web1/config/config.htm). It seems to be the more elegant way.

Now i can create the config object but the events evOnConfigItemsReceived, evOnConfigLoaded and evOnConfigSaveResult were never called.The "config.init" function is called, but no events are raised.
Do you know why this happens?


config_wont_init.PNG

Picture of Marc Schodermayr (innovaphone)
Moderator Registered 9 years 201 days
Marc Schodermayr (innovaphone) Friday, 27 August 2021, 02:57 PM
Re: Customize PBX Manager Plugin
The config library uses an event mechanism for the callbacks by assigning an innovaphone.lib1.Event instance. If you just assign them (like "config.evOnConfigLoaded = onConfigLoaded"), the event instance will be overwritten and thus never reaised. So try out the following instead:

config.evOnConfigItemsReceived.attach(onConfigItemsReceived);
config.evOnConfigLoaded.attach(onConfigLoaded);
config.evOnConfigSaveResult.attach(onConfigSaveResult)

This should do the trick.

I also saw that the documentation is wrong at this point. I'm sorry for that. sad
Picture of mitop
Registered 3 years 291 days
mitop Monday, 6 September 2021, 12:01 PM
Re: Customize PBX Manager Plugin
Hi,

thank you for the trick...unfortunately, I can't yet report that the Javascript side is working sad
My C++ Config side stops working, and i have no idea why. On Wednesday, 18 August 2021 i posted that it works, and now, no chance to get it running sad. The config table is still created, but the initial values are no longer written to the table. I have tried everything I can think of, but I can't get it to work.
I the zip file attached, you will find the app log file and the coredump and screenshots of the code.


mr_innova_sdk_configcontext.zip
Picture of mitop
Registered 3 years 291 days
mitop Monday, 6 September 2021, 12:17 PM
Re: Customize PBX Manager Plugin
...maybe the InstaceLog is now a problem...
from the code example (https://sdk.innovaphone.com/13r1/common/lib/config.htm) "Using Config" i should do this:

this->config = new MyConfig(this, this->database, this->log);

But calling it that way, ends up in a Segementation fault error. So i call it
that this way:
this->config = new MyConfig(this, this->database, this);
(two weeks ago it works that way)

But maybe i`m on the wrong track here...


Are there any other files that we can use for error analysis than the ones in the zip file from my previous post?

6_repli_myapp_dek_log.PNG

Picture of mitop
Registered 3 years 291 days
mitop Friday, 17 September 2021, 09:56 AM in response to mitop
Re: Customize PBX Manager Plugin
Got it big grin ... the manager plugin is not finished yet, but we can exchange values through the Config class
Picture of mitop
Registered 3 years 291 days
mitop Monday, 4 October 2021, 09:59 PM in response to Marc Schodermayr (innovaphone)
Re: Customize PBX Manager Plugin
Hi Marc,

your trick was good for the usual myapp.js part and testing smile and i think it will work in the myapp-admin.js file too. We have almost finished our App (first beta release upcomming) and now we get stucked.

When using Config class in myapp-manager.js it won`t create the Config object at all. I observed the same behavior when I forgot to add the line:

"<script src="web/config/innovaphone.config.js" type="text/javascript"></script>"

to the htm file for the myapp.js. The myapp-manager has no htm file.
We added the config.mak everywhere to get it running, and added:

"/// <reference path="../../sdk/web1/config/innovaphone.config.js" />"

to myappmanager.js
So is there another trick to get the Config class running inside the myapp-manager plugin?

We are running out of ideas sad
The rest is almost ready smile
Picture of mitop
Registered 3 years 291 days
mitop Thursday, 7 October 2021, 04:25 PM
Re: Customize PBX Manager Plugin
Hi again,

we decided to place the functionality and Config class inside the Apps-Admin part and it works great. Maybe in another release the Config Class will work inside the Apps-Manager part too, but time is short at the moment. If i had been sure i was going in the right direction, i would have kept experimenting with the manager and config. But currently we need to get into the testing phase with foreign users to move forward.
We are just happy to be able to release the first beta of our app...soon there will be more information about it wink smile

Picture of mitop
Registered 3 years 291 days
mitop Monday, 4 October 2021, 10:17 PM in response to Carmen Álvarez Méndez (innovaphone)
Re: Customize PBX Manager Plugin
Hi,

to get the Config Class running inside the myappmanager.js file i need to do this here, as Carmen has already mentioned:

"
To get config items on the Javascript side you can start another App Websocket connection with your app and if you are using the Config Library, do something like this:
usersWS = new innovaphone.appwebsocket.Connection(usersURL.replace("http", "ws"), "-", null, app.domain, usersConnected, usersMessage, null, null, usersLogin);
function usersLogin(app, challenge) {
var srcus = new managerApi.Src(getlogin);
srcus.send({ mt: "GetInstanceLogin", path: item.apUri.slice(0, item.apUri.lastIndexOf("/")), app: app, challenge: challenge }, item.ap);
function getlogin(obj) {
usersWS.login(obj.msg);
srcus.close();
}
}

function usersConnected() { usersWS.send({ api: "Config", mt: "ReadConfig" }); }

function usersMessage(msg) {
if (msg.mt == "ReadConfigResult") {
// Example with the Users Config Items
allowDelete = msg.ConfigItems.allowDelete;
pbxReplicator = msg.ConfigItems.pbxName;
changeConfig();
usersWS.close();
}
}
"

My assumption was that a login has already been made. Just remember something with multiple connections that need to be established. In the other two files (myapp.js and myapp-manager.js) the code was shorter, assumed there was something like that for the manager part too.
← You can define your color theme preference here