Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]: Bundling of retroshare-service apk using QT #2

Merged
merged 6 commits into from Jun 17, 2021

Conversation

Kumaravinash9
Copy link
Contributor

@Kumaravinash9 Kumaravinash9 commented Jun 5, 2021

Fix : #3
Fix : #10

@csoler
Copy link
Contributor

csoler commented Jun 8, 2021

I merged the original PR, so I suppose this one should be rebased on the existing code.

@Kumaravinash9
Copy link
Contributor Author

Kumaravinash9 commented Jun 8, 2021

I merged the original PR, so I suppose this one should be rebased on the existing code.

ok @csoler. This PR is not completed yet. This require some more changes. Once it will complete, I will let you know then after you will merge this pull request.

@Kumaravinash9
Copy link
Contributor Author

Kumaravinash9 commented Jun 8, 2021

Finally I have implemented this feature. Now, we do not need to download retroshare-service apk.
PreView:

WhatsApp.Video.2021-06-08.at.23.11.31.mp4

@Kumaravinash9 Kumaravinash9 changed the title [WIP]: Retroshare_service bundle [WIP]: Bundling of retroshare-service apk using QT Jun 8, 2021
@Kumaravinash9
Copy link
Contributor Author

Kumaravinash9 commented Jun 11, 2021

@defnax @csoler where are the login jsonapi available ? I am facing problem in this api. I want to recheck this api route in retroshare. So I can check the parameters of this request.

final accountDetails = {
      "location": {
        "mLocationName": nodeName,
        "mPgpName": username,
      },
      "password": password,
      'makeHidden': false,
      'makeAutoTor': false
    };
  final response = await http.post(
      'http://localhost:9092/rsLoginHelper/createLocation',
      body: json.encode(accountDetails));

  if (response.statusCode == 200 && json.decode(response.body)['retval']) {
    dynamic resp = json.decode(response.body)['location'];
    Account account = Account(resp['mLocationId'], resp['mPgpId'],
        resp['mLocationName'], resp['mPgpName']);

    return Tuple2<bool, Account>(json.decode(response.body)['retval'], account);
  } else {
    throw Exception('Failed to load response');
  }

@defnax
Copy link

defnax commented Jun 12, 2021

i dont know about these maybe ask
@kdebiec @b1rdG @G10h4ck @rottencandy

@Kumaravinash9
Copy link
Contributor Author

i dont know about these maybe ask
@kdebiec @b1rdG @G10h4ck @rottencandy

Thanks @defnax.

@selankon
Copy link

Hi

@defnax @csoler where are the login jsonapi available ? I am facing problem in this api. I want to recheck this api route in retroshare. So I can check the parameters of this request.

final accountDetails = {
      "location": {
        "mLocationName": nodeName,
        "mPgpName": username,
      },
      "password": password,
      'makeHidden': false,
      'makeAutoTor': false
    };
  final response = await http.post(
      'http://localhost:9092/rsLoginHelper/createLocation',
      body: json.encode(accountDetails));

  if (response.statusCode == 200 && json.decode(response.body)['retval']) {
    dynamic resp = json.decode(response.body)['location'];
    Account account = Account(resp['mLocationId'], resp['mPgpId'],
        resp['mLocationName'], resp['mPgpName']);

    return Tuple2<bool, Account>(json.decode(response.body)['retval'], account);
  } else {
    throw Exception('Failed to load response');
  }

You can find the API defined on this headers: https://github.com/RetroShare/RetroShare/tree/master/libretroshare/src/retroshare

You hace to use the createLocationV2 method to create a location.

Another trick, from your computer, with your phone conected, you can talk with the android retroshare service using:

adb forward tcp:9091 tcp:9092   # This will redirect your computer 9091 port to the 9092 on your phone
# Then use curl to test API endpoints
curl -u "test:test" -d '{ "forumId" : "5abe40ea3f194a69b066ec58d6063a03" }'  http://127.0.0.1:9091/rsGxsForums/getForumsSummaries  

This will help you to debug your problems

@Kumaravinash9
Copy link
Contributor Author

Hi

@defnax @csoler where are the login jsonapi available ? I am facing problem in this api. I want to recheck this api route in retroshare. So I can check the parameters of this request.

final accountDetails = {
      "location": {
        "mLocationName": nodeName,
        "mPgpName": username,
      },
      "password": password,
      'makeHidden': false,
      'makeAutoTor': false
    };
  final response = await http.post(
      'http://localhost:9092/rsLoginHelper/createLocation',
      body: json.encode(accountDetails));

  if (response.statusCode == 200 && json.decode(response.body)['retval']) {
    dynamic resp = json.decode(response.body)['location'];
    Account account = Account(resp['mLocationId'], resp['mPgpId'],
        resp['mLocationName'], resp['mPgpName']);

    return Tuple2<bool, Account>(json.decode(response.body)['retval'], account);
  } else {
    throw Exception('Failed to load response');
  }

You can find the API defined on this headers: https://github.com/RetroShare/RetroShare/tree/master/libretroshare/src/retroshare

You hace to use the createLocationV2 method to create a location.

Another trick, from your computer, with your phone conected, you can talk with the android retroshare service using:

adb forward tcp:9091 tcp:9092   # This will redirect your computer 9091 port to the 9092 on your phone
# Then use curl to test API endpoints
curl -u "test:test" -d '{ "forumId" : "5abe40ea3f194a69b066ec58d6063a03" }'  http://127.0.0.1:9091/rsGxsForums/getForumsSummaries  

This will help you to debug your problems

But my question is why this above code is not working.

@selankon
Copy link

Hi,

  • Use createLocationV2 method
  • Use curl with --verbose option to check if RetroShare service is running
  • What is the response status code? The retval value?

@Kumaravinash9
Copy link
Contributor Author

  • option to check if RetroShare service is running

I am using the isRetroshareRunning function for checking retro share is running or not like elrepo.io do and the return type of isRetroshareRunning is coming true that means retroshare is running in background

@selankon
Copy link

Hi @Kumaravinash9

Try to debug the response, use the method I suggested, check the response status code etc... We need more info to diagnosticate the problem..

@Kumaravinash9
Copy link
Contributor Author

Kumaravinash9 commented Jun 12, 2021

Hi @Kumaravinash9

Try to debug the response, use the method I suggested, check the response status code etc... We need more info to diagnosticate the problem..

It worked with createLocationV2 method but many pervious api calls is not working after adding retroshare_service using qt. I just want to know why this calls is not working. These API call are also not working. They just return none in response.

Future<bool> checkExistingAuthTokens(String locationId, String password) async {
  print("hello");
  final response = await http.get(
      '$RETROSHARE_SERVICE_PREFIX/RsJsonApi/getAuthorizedTokens',
      headers: {
        HttpHeaders.authorizationHeader:
            'Basic ' + makeAuthHeader(locationId, password)
      });
  print(response.statusCode);

  if (response.statusCode == 200) {
    for (LinkedHashMap<String, dynamic> token
        in json.decode(response.body)['retval']) {
      if (token['key'] + ":" + token['value'] == authToken.toString())
        return true;
    }
    authorizeNewToken(locationId, password);
    return true;
  } else if (response.statusCode == 401) {
    return false;
  } else
    throw Exception('Failed to load response');
}

void authorizeNewToken(String locationId, String password) async {
  final response = await http.post(
      '$RETROSHARE_SERVICE_PREFIX/RsJsonApi/authorizeToken',
      body: json.encode({'token': '$authToken'}),
      headers: {
        HttpHeaders.authorizationHeader:
            'Basic ' + base64.encode(utf8.encode('$locationId:$password'))
      });

  if (response.statusCode == 200) {
    return;
  } else
    throw Exception('Failed to load response');
}

one more problem I am facing sometimes this exception showed up which crash the app

java.lang.RuntimeException: Unable to start receiver cc.retroshare.retroshare.ServiceStart: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=cc.retroshare.retroshare/.RetroShareServiceAndroid }: app is in background uid UidRecord{a16b543 u0a333 RCVR idle change:uncached procs:1 seq(0,0,0)}

@Kumaravinash9
Copy link
Contributor Author

@csoler Now, everything is working properly. Now it's ready to merge.

@csoler
Copy link
Contributor

csoler commented Jun 13, 2021

I tried to run this PR from linux. It seems that something's missing: "flutter run" generates the following errors:

ERROR: lib/common/input_chips/chips_input.dart:67:7: Error: The non-abstract class 'ChipsInputState' is missing implementations for these members:
ERROR: - TextInputClient.currentAutofillScope
ERROR: - TextInputClient.performPrivateCommand

ERROR: ../../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.5.4/lib/flutter_redux.dart:77:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
ERROR: - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/framework.dart').
and

ERROR: ../../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.5.4/lib/flutter_redux.dart:79:14: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.

@Kumaravinash9
Copy link
Contributor Author

I tried to run this PR from linux. It seems that something's missing: "flutter run" generates the following errors:

ERROR: lib/common/input_chips/chips_input.dart:67:7: Error: The non-abstract class 'ChipsInputState' is missing implementations for these members:
ERROR: - TextInputClient.currentAutofillScope
ERROR: - TextInputClient.performPrivateCommand

ERROR: ../../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.5.4/lib/flutter_redux.dart:77:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
ERROR: - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/framework.dart').
and

ERROR: ../../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.5.4/lib/flutter_redux.dart:79:14: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.

@csoler which flutter version are you using.sometimes these problem are usual when flutter version is different. In windows, it's is not showing any error.

@csoler
Copy link
Contributor

csoler commented Jun 14, 2021

I'm using 2.2.1 on Ubuntu 20.04. Seems these errors are not complicated to fix. It looks like these functions are not used and the compiler only complains as error instead of warning. Defining them as doing nothing should fix it right?

@selankon
Copy link

Hi @csoler it seem that could be a problem with flutter version that has deprecated some plugins... Maybe.

For ChipsInput maybe you can use directly a plugin that do this instead of use .the code there. For flutter redux maybe you can try to upgrade the version on pubspec.yaml

@Kumaravinash9 as I understand, the not working method is /RsJsonApi/authorizeToken right? Try to use /rsJsonApi/authorizeUser instead.

@Kumaravinash9
Copy link
Contributor Author

Kumaravinash9 commented Jun 14, 2021

I'm using 2.2.1 on Ubuntu 20.04. Seems these errors are not complicated to fix. It looks like these functions are not used and the compiler only complains as error instead of warning. Defining them as doing nothing should fix it right?

You are using the latest version of flutter. There are many packages are not working properly with the new version of flutter like redux in this module.

Run the following command to see a list of available versions.

flutter version

Then choose a version you want to switch to by running

flutter version v1.17.1 ( i am using this version now)

@Kumaravinash9
Copy link
Contributor Author

Kumaravinash9 commented Jun 14, 2021

Hi @csoler it seem that could be a problem with flutter version that has deprecated some plugins... Maybe.

For ChipsInput maybe you can use directly a plugin that do this instead of use .the code there. For flutter redux maybe you can try to upgrade the version on pubspec.yaml

@Kumaravinash9 as I understand, the not working method is /RsJsonApi/authorizeToken right? Try to use /rsJsonApi/authorizeUser instead.

already added by taking a help of elrepo-lib repo

@csoler
Copy link
Contributor

csoler commented Jun 14, 2021

flutter version v1.17.1
WARNING: Flutter version command has been removed, using latest from channel

@Kumaravinash9
Copy link
Contributor Author

Kumaravinash9 commented Jun 14, 2021

flutter version v1.17.1
WARNING: Flutter version command has been removed, using latest from channel

Once have a look at this link https://stackoverflow.com/questions/49468321/how-to-downgrade-flutter-sdk-dart-1-x and try to migrate the flutter version to flutter version v1.17.1

@csoler
Copy link
Contributor

csoler commented Jun 14, 2021

Sorry to ask that, but why do we have to stick with an old---unsupported---version of flutter for this project? Isn't that counterproductive?

Also I really lack time now, so I can't spend too long debugging why flutter doesn't allow me to downgrade.

@Kumaravinash9
Copy link
Contributor Author

Sorry to ask that, but why do we have to stick with an old---unsupported---version of flutter for this project? Isn't that counterproductive?

Also I really lack time now, so I can't spend too long debugging why flutter doesn't allow me to downgrade.

Actually i have already planned to migrate the flutter version of repo with new version in second phase of gsoc. Before migrating the version, i want to understand the whole source code because some widgets and plugins has deprecated. That will required lot of changes that's why i planned to upgrade this version in second phase of GSOC.

@selankon
Copy link

Hi @Kumaravinash9

I guess there won't be much differences if you try to just upgrade flutter redux, maybe is easier for everybody :)

FYI:

PS: just a little warning. You will find some code inconsistencies: flutter redux is partially implemented, sometimes you will see
API calls on redux_middleware and sometimes on services/ folder. Also, sometimes the API is called using the
API wrapper and others using dart http calls. This is because new technologies were implemented after some
part of the code was already written, which is not yet adapted to those...

So just to warn you that the code is a little "Frankenstein Code". Also, it only supports in a buggy way the old and deprecated RetroShare chat system. (just for your information)

In my opinion, if you give support for forums will be absolutely awesome and I will make a golden statue of "you using retroshare in your phone" :) .

@Kumaravinash9
Copy link
Contributor Author

Kumaravinash9 commented Jun 14, 2021

Hi @Kumaravinash9

I guess there won't be much differences if you try to just upgrade flutter redux, maybe is easier for everybody :)

FYI:

PS: just a little warning. You will find some code inconsistencies: flutter redux is partially implemented, sometimes you will see
API calls on redux_middleware and sometimes on services/ folder. Also, sometimes the API is called using the
API wrapper and others using dart http calls. This is because new technologies were implemented after some
part of the code was already written, which is not yet adapted to those...

So just to warn you that the code is a little "Frankenstein Code". Also, it only supports in a buggy way the old and deprecated RetroShare chat system. (just for your information)

In my opinion, if you give support for forums will be absolutely awesome and I will make a golden statue of "you using retroshare in your phone" :) .

Thanks @selankon. I didn't have info about this problem. Now,I will update the repo with current version then.

@Kumaravinash9
Copy link
Contributor Author

Hello @csoler. I have updated the repo with newer version. Have a look please. Some changes still needed but we can use the app now.

@Kumaravinash9
Copy link
Contributor Author

Preview :

WhatsApp.Video.2021-06-15.at.23.20.08.mp4

@csoler
Copy link
Contributor

csoler commented Jun 15, 2021 via email

@csoler csoler merged commit a912f31 into RetroShare:master Jun 17, 2021
obrasero pushed a commit to obrasero/retroshare-mobile that referenced this pull request Aug 12, 2021
@Kumaravinash9 Kumaravinash9 deleted the retroshare_bundle branch August 26, 2021 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need migration of the project to the flutter newer version Bundle retroshare service with the application
4 participants