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

Cloud Storage #142

Closed
shariatraad opened this issue Jan 10, 2020 · 5 comments
Closed

Cloud Storage #142

shariatraad opened this issue Jan 10, 2020 · 5 comments

Comments

@shariatraad
Copy link

Is QtFirebase Cloud Storage still unavailable for c++? And I also noticed that real-time database is partially available. What functions are still not accessible?

@shariatraad
Copy link
Author

A simple way to use Qtfirebase Real-time data base is this

  1. Add a child named "tests" to your Database/Data in firebase consul.

  2. Change your Database/Rules (Json file) in your firebase consul to :

{
  /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
  "rules": {
    ".read": true,
    ".write": true
  }
}
  1. In your .h file include:
    QAndroidJniEnvironment *_jniEnv;
    ::firebase::App* _app;
    ::firebase::ModuleInitializer _initializer;
    QAndroidJniObject _jniObj;
    firebase::database::Database *database;
  1. In your .cpp file include:
    _jniEnv = new QAndroidJniEnvironment();
    QAndroidJniObject jniObject = QtAndroid::androidActivity();
    ::firebase::App *instance = ::firebase::App::GetInstance();

    if (instance) {
        qDebug() << "instance already exists";
        _app = instance;
    } else {
        qDebug() << "Creating instance";
        jniObject = QtAndroid::androidActivity();
        _app = ::firebase::App::Create(*_jniEnv, jniObject.object<jobject>());
    }
    database=firebase::database::Database::GetInstance(_app);
    firebase::database::DatabaseReference dbref = database->GetReferenceFromUrl("Enter Your Real-time Database URL Here");

    dbref.Child("tests").SetValue(Add Your Custom Value Here);

@shariatraad
Copy link
Author

shariatraad commented Jan 10, 2020

(But I still wonder if there is a way to use Qtfirebase Cloud Storage and what functions are unavailable for Real-time Database)

@larpon
Copy link
Owner

larpon commented Jan 10, 2020

Hi! Thanks for your interest!

Is QtFirebase Cloud Storage still unavailable for c++?

Yes, I'm currently unaware of the status. Maybe @Furkanzmc can give you more information on the status. If it's abandoned you're welcome to contribute an implementation!

And I also noticed that real-time database is partially available. What functions are still not accessible?

Correct. It need to be expanded further to cover the complete API. Pull requests are welcome!
A quick grep through the code base for db:: (namespace db = ::firebase::database). Reveals this list of calls used:

qtfirebasedatabase.cpp
26:        m_db = db::Database::GetInstance(qFirebase->firebaseApp());

qtfirebasedatabase.h
67:    firebase::database::Database* m_db;
192:    firebase::database::DatabaseReference m_dbRef;

qtfirebasedatabase.cpp
10:    , m_db(nullptr)
26:        m_db = db::Database::GetInstance(qFirebase->firebaseApp());
230:            m_dbRef = qFirebaseDatabase->m_db->GetReference().GetRoot();
234:            m_dbRef = qFirebaseDatabase->m_db->GetReference().GetRoot().Child(path.toUtf8().constData());
244:        m_pushChildKey = m_dbRef.PushChild().key();
255:        firebase::Future<void> future = m_dbRef.RemoveValue();
268:            m_dbRef = m_dbRef.Child(m_pushChildKey.toUtf8().constData());
270:        firebase::Future<void> future = m_dbRef.SetValue(QtFirebaseService::fromQtVariant(value));
289:            firebase::Future<firebase::database::DataSnapshot> future = m_dbRef.GetValue();
302:    firebase::Future<void> future = qFirebaseDatabase->m_db->GetReference().UpdateChildren(vfb);
385:        m_query.setQuery(m_dbRef.OrderByKey());
392:        m_query.setQuery(m_dbRef.OrderByValue());
399:        m_query.setQuery(m_dbRef.OrderByChild(path.toUtf8().constData()));
406:        m_query.setQuery(m_dbRef.OrderByPriority());
413:        m_query.setQuery(m_dbRef.StartAt(QtFirebaseService::fromQtVariant(order_value)));
421:        m_query.setQuery(m_dbRef.StartAt(QtFirebaseService::fromQtVariant(order_value), child_key.toUtf8().constData()));
428:        m_query.setQuery(m_dbRef.EndAt(QtFirebaseService::fromQtVariant(order_value)));
435:        m_query.setQuery(m_dbRef.EndAt(QtFirebaseService::fromQtVariant(order_value), child_key.toUtf8().constData()));
442:        m_query.setQuery(m_dbRef.EqualTo(QtFirebaseService::fromQtVariant(order_value)));
449:        m_query.setQuery(m_dbRef.EqualTo(QtFirebaseService::fromQtVariant(order_value), child_key.toUtf8().constData()));
456:        m_query.setQuery(m_dbRef.LimitToFirst(limit));
463:                m_query.setQuery(m_dbRef.LimitToLast(limit));

So the API calls not available, are the ones missing from this list plus what's not present in qtfirebasedatabase.h.
I remember another issue where some of the missing functionality at the time was also mentioned.
So you'll have to do some investigation to find out the exact missing calls I guess.

Thanks for the quick example - much obliged!

(But I still wonder if there is a way to use Qtfirebase Cloud Storage ...)

There is only a way to use Cloud Storage through QtFirebase if someone contributes a wrap of storage.h - It looks pretty straight forward at first glance. I would be very cool to have it contributed!
... Untill then you're stuck with using it straight from the Firebase C++ SDK as provided by Google

@shariatraad
Copy link
Author

shariatraad commented Jan 10, 2020

@larpon Hello Larpon.
Thank you so much for your time and the detailed answer. It is all clear now! :) If I come up with a wrapper or find something helpful I will share it with you.
The example I provided is the most basic one just to make sure if you are successfully connected to the database. Thought it might be helpful for some beginners.

@larpon
Copy link
Owner

larpon commented Jan 10, 2020

@shariatraad no problem - thanks for showing your interest in the project!
People tend to contribute just wrappers for what they need on a per project basis - so that's why some of the larger components are missing features. So we expand only when people need the functionality - and are kind enough to contribute code back :)

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

No branches or pull requests

2 participants