Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
Permissions = Non_Authorized_Runtime_Permissions
Kvs.Initialize(File.DirInternal,"riolivre")
NativeMe.InitializeContext
SdkVersion = Phone1.SdkVersion
'Kvs.DeleteAll
'File.Delete(File.DirInternal,"nexphone.db")
'Values from 0 to 30... from 0 to 1, reduce, above 1, aplify
If Not(Kvs.ContainsKey("miclevelradio")) Then
Kvs.Put("miclevelradio",10)
Kvs.put("speakerlevelradio",10)
Kvs.Put("miclevelphone",12)
Kvs.Put("speakerlevelphone",10)
End If
If File.Exists(File.DirInternal,"voice_note_start.wav") = False Then
File.Copy(File.DirAssets,"voice_note_start.wav",File.DirInternal,"voice_note_start.wav")
File.Copy(File.DirAssets,"voice_note_stop.wav",File.DirInternal,"voice_note_stop.wav")
File.Copy(File.DirAssets,"voice_note_error.wav",File.DirInternal,"voice_note_error.wav")
End If
If Not(File.Exists(File.DirInternal,"placedetails.db")) Then
File.Copy(File.DirAssets,"placedetails.db",File.DirInternal,"placedetails.db")
End If
If Not(File.Exists(File.DirInternal,"profile.png")) Then
File.Copy(File.DirAssets,"actionbar_button_person_dark.png",File.DirInternal,"profile.png")
End If
If Not(File.Exists(File.DirInternal,"genericnotify.png")) Then
File.Copy(File.DirAssets,"actionbar_button_person_dark.png",File.DirInternal,"genericnotify.png")
End If
If Not(Kvs.ContainsKey("country")) Then
Kvs.Put("country","br")
End If
If Not(Kvs.ContainsKey("radiocallstarted")) Then
Kvs.Put("radiocallstarted",False)
End If
Kvs.Put("chamadaemcurso",False)
If Not(Kvs.ContainsKey("radioactive")) Then
Kvs.Put("radioactive",False)
End If
'Nb.Initialize
Sql1.Initialize(File.DirInternal,"nexphone.db",True)
Dim Query As String
'Query = "drop table radiohistory"
'Sql1.ExecNonQuery(Query)
'Query = "drop table busca"
'Sql1.ExecNonQuery(Query)
'Query = "drop table contacts"
'Sql1.ExecNonQuery(Query)
'Query = "drop table indications"
'Sql1.ExecNonQuery(Query)
Dim DbUpdate As Boolean = False
If Kvs.ContainsKey("database-done") = False Then
DbUpdate = True
Else
If Kvs.Get("database-done") <> "43.1.0" Then DbUpdate = True
End If
If DbUpdate = True Then
Kvs.Put("database-done","43.1.0")
Query = "create table if not exists radiohistory (id integer PRIMARY KEY,iduser integer,login text,nome text,company text,mobile text,googleid text,start real,answer real,end real,status text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists busca (id integer PRIMARY KEY,login text,nome text,company text,mobile text,datahora real,googleid text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists contacts (id integer PRIMARY KEY,login text,nome text,company text,mobile text,datahora real,googleid text) "
Sql1.ExecNonQuery(Query)
Query = "create table if not exists indications (googleid text PRIMARY KEY,photoreference text,company text,nome text,telefone text,celular text,datahora real,enviada integer default 0) "
Sql1.ExecNonQuery(Query)
Query = "create table if not exists addedplaces (googleid text PRIMARY KEY,latitude text,longitude text,accuracy text,name text,phone_number text,address text,types text,website text,language text,datahora real)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists chats (id text primary key,title text,description text,logofile text,created real,id_creator integer,is_active int," _
& "is_pro int,daysofweek text,starthour int,startminute int,endhour int,endminute int,chat_active real)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists messages (id text primary key,chatid text,source int,target int,msgcreated real, msgsent real, msgreceived real,msgread real,media_url text " _
& ",media_mime_type,media_size int,media_name text,media_caption text,media_duration int,latitude real,longitude real,thumb_image text,msgdata text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists messagestemp (id text primary key,chatid text,source int,target int,msgcreated real, msgsent real, msgreceived real,msgread real,media_url text " _
& ",media_mime_type,media_size int,media_name text,media_caption text,media_duration int,latitude real,longitude real,thumb_image text,msgdata text)"
Sql1.ExecNonQuery(Query)
'#### TODO - CREATE UNIQUE STATEMENT
Query = "create table if not exists chat_users (iduser int,idchat text,starttime real,endtime real,isadmin int,primary key (iduser,idchat) )"
Sql1.ExecNonQuery(Query)
Try
Query = "alter table chat_users add nome text"
Sql1.ExecNonQuery(Query)
Query = "alter table chat_users add login text"
Sql1.ExecNonQuery(Query)
Query = "alter table chat_users add company text"
Sql1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
Try
Query = "create index idx_msgcreated on messages (msgcreated)"
Sql1.ExecNonQuery(Query)
Query = "create index idx_chatid on messages (chatid)"
Sql1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
'### TODO - END UNIQUE STATEMENT
Query = "create table if not exists msgqueue (id int,iduser int,msgdata text,datetime real)"
Sql1.ExecNonQuery(Query)
'Query = "delete from upmediaqueue"
'Sql1.ExecNonQuery(Query)
Query = "create table if not exists upmediaqueue (id int,iduser int,msgdata text,datetime real)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists compressmediaqueue (id int,mediatype text,chatid text,messageid text,msgstring text,situation text,datetime real)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists chatselected (id int primary key)"
Sql1.ExecNonQuery(Query)
Query = "alter table chatselected add idchat text"
Try
Sql1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
Query = "create table if not exists downqueue (id int,msgdata text,datetime real)"
Sql1.ExecNonQuery(Query)
Query = "alter table contacts add lastuse real default 0"
Try
Sql1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
Query = "create table if not exists messagestatus (messageid text,chatid text,userid int,msgdelivered real,msgread real,primary key (messageid,userid))"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists downmediaqueue (id int primary key,chatid text,medialink text,mediafile text,mimetype text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists userselected (id int primary key,login text,nome text,company text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists messageselected (id text primary key,chatid text,media_mime_type text)"
Sql1.ExecNonQuery(Query)
End If
Dim ExtenFolder As String = rp.GetSafeDirDefaultExternal("shared")
File.copy(File.DirAssets,"radioshort.wav", ExtenFolder ,"radioshort.wav")
File.copy(File.DirAssets,"radiolong.wav",ExtenFolder ,"radiolong.wav")
File.copy(File.DirAssets,"radiook.wav",ExtenFolder ,"radiook.wav")
File.copy(File.DirAssets,"radiorefuse.wav",ExtenFolder ,"radiorefuse.wav")
File.copy(File.DirAssets,"radiostart.wav",ExtenFolder ,"radiostart.wav")
File.copy(File.DirAssets,"msgting.mpeg",ExtenFolder ,"msgting.mpeg")
File.Copy(File.DirAssets,"missed_radio.png",ExtenFolder,"missed_radio.png")
File.Copy(File.DirAssets,"largecall.png",ExtenFolder,"largecall.png")
File.Copy(File.DirAssets,"oncall.png",ExtenFolder,"oncall.png")
Initialize_Voip
End Sub