Version 0.002 with working Permissions

This commit is contained in:
LubuWest 2016-12-04 18:28:52 +01:00
commit 15e2e8f60a
62 changed files with 924 additions and 1277 deletions

View file

@ -17,9 +17,9 @@ TabView{
id:root
tabPosition: Qt.BottomEdge
width: Screen.desktopAvailableWidth
height: Screen.desktopAvailableHeight
height: Screen.desktopAvailableHeight
property var db: ["Photos", "1.0", "Stores Friendica data", 100000000]
property var db: ["Friendiqa", "1.0", "Stores Friendica data", 100000000]
property var login: Service.readActiveConfig(db)
property var contactlist: []
property real mm: Screen.pixelDensity
@ -44,7 +44,7 @@ TabView{
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
}
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
//print("Current contact"+JSON.stringify(newContacts[currentContact]));
//print("Current contact"+JSON.stringify(newContacts[currentContact])+newContacts.length);
if(currentContact<newContacts.length){
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
@ -67,22 +67,23 @@ TabView{
}
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
if (isFriend==1){
var suffix=contact.profile_image_url.substring(contact.profile_image_url.lastIndexOf("."), contact.profile_image_url.length);
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+suffix;
// if (isFriend==1){
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
xhr.setFilename(imagename);
xhr.download();
}
//}
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
var result;
db.transaction( function(tx) {
result = tx.executeSql('SELECT * from contacts where id = '+contact.id); // check for news id
result = tx.executeSql('SELECT * from contacts where username="'+root.login.username+'" AND id = '+contact.id); // check for news id
if(result.rows.length === 1) {// use update
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where username="'+root.login.username+'" AND id='+contact.id);
} else {// use insert
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
});
if (isFriend!=1){root.currentContact=root.currentContact+1}
//if (isFriend!=1){root.currentContact=root.currentContact+1}
}
Connections{
@ -91,7 +92,14 @@ TabView{
}
Connections{
target:xhr
onError:{print("Error"+data)}
onError:{print("Error"+data);
var database=LocalStorage.openDatabaseSync(root.db[0],root.db[1],root.db[2],root.db[3]);
var result;
database.transaction( function(tx) {
print("Error for "+JSON.stringify(newContacts[currentContact]));
//print('UPDATE contacts SET profile_image="" where username="'+root.login.username+'" AND id = '+newContacts[currentContact].id);
result = tx.executeSql('UPDATE contacts SET profile_image="" where username="'+root.login.username+'" AND id = '+newContacts[currentContact].id);
root.currentContact=root.currentContact+1})}
}
Component.onCompleted: {
if (login==""){Service.initDatabase(db)}
@ -121,24 +129,24 @@ style: TabViewStyle {
title: qsTr("News")
id: newstab
property string newstabStatus:"news"
source: "qrc:/qml/NewsTab.qml"
source: "qrc:/qml/newsqml/NewsTab.qml"
}
Tab{
title: qsTr("Contacts")
id: friendstab
source: "qrc:/qml/FriendsTab.qml"
source: "qrc:/qml/contactqml/FriendsTab.qml"
}
Tab{
title: qsTr("Photos")
id: fotostab
source: "qrc:/qml/PhotoTab.qml"
source: "qrc:/qml/photoqml/PhotoTab.qml"
}
Tab{
title: qsTr("Config")
source: "qrc:/qml/ConfigTab.qml"
source: "qrc:/qml/configqml/ConfigTab.qml"
}
}