Same file modified by two users

Started by Andrés Chandía, July 19, 2010, 03:59:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrés Chandía

We have managed to put the fet files at a samba server, so the same files can be edited by a group of persons, the thing is that now we are looking for an option that allows you to see the file if somebody else is using it but without possibilities of editing it while in process by somebody else. Is there a way to do this?
Thanks for helping.
@ch

Liviu Lalescu

#1
Maybe you can do that: when a person opens the .fet file (first person), create a "name_of_file.locked". When the person closes the .fet file, remove that .locked file. Another person can open the .fet file, but cannot save if there exists a .locked file.

One problem: 1st user opens .fet file (F_Version_1), 2nd user opens .fet file, 1st user modifies, saves, closes, now 2nd user does a minor change (to the original file, F_Version_1), saves. The 1st user's modifications are lost. So maybe change above method, so that if second user opens file and .locked exists, he cannot save the file until he opens it again.

This can be implemented easily in FET, I can tell you where (in src/engine/rules.cpp, function read (line 5133) and function write (line 7019), maybe alternatively in src/interface/fetmainform.cpp, function on_fileOpenAction_activated (line 784) and function fileSaveAs (line 866)).

Edited to add: and function fileSave (fetmainform.cpp, line 1284).

Andrés Chandía

Thanks again,
I will try it, to do it on windows installations, how should I proceed, I mean, should I do all of the changes once fet is installed or before,  and if it's before, how?
@ch

Liviu Lalescu

QuoteThanks again,
I will try it, to do it on windows installations, how should I proceed, I mean, should I do all of the changes once fet is installed or before,  and if it's before, how?

I do not understand. Of course you need to change the sources of FET, compile and install (that is the order).

What do you mean by: "if it's before, how?"?

Andrés Chandía

the thing is, in windows you download the zipped file, you expand it and you use it, no installation, that is the question related to.
@ch

Liviu Lalescu

#5
Quotethe thing is, in windows you download the zipped file, you expand it and you use it, no installation, that is the question related to.

Unpack fet-v.v.v.exe. You obtain the directory fet-v.v.v. In this directory, you can keep all the files, without fet.exe. You need to obtain a new fet.exe by compiling from sources, then overwrite your custom fet.exe over official fet.exe. Then, you have the whole directory and you can archive it, make it a self extracting archive, as you wish.

Or, you can get the sources (tar.bz2) FET, unpack, modify the sources as I told you, compile, eventually remove the src and tmp directories and files Makefile and fet.pro - then you obtain the same structure as above, containing the new fet.exe (so, no need to care about other details). Make it an archive, as above (the important and different from official archive is only fet.exe, which you obtain after compiling).

To compile, you need to get Qt and MinGW (or other C++ compiler), and follow the other advice in FET README. Modify the .cpp files, as I told you. Then compile. After compilation, you will get a new fet.exe file - this is the only file different from the official files.

Let me know if it is clear now.

Andrés Chandía

Ok, so I can do the whole compiling process in linux and then install fet on windows?
@ch

Liviu Lalescu

#7
QuoteOk, so I can do the whole compiling process in linux and then install fet on windows?

Oh, no :-) . How can you run a GNU/Linux program under Windows?

You can modify FET sources under GNU/Linux, test them, then copy them under Windows and compile under Windows (using MinGW or MSVC, with Qt for Windows installed).

There may be other possibility: get mingw32 (with qt) libraries under GNU/Linux and do a cross-compile. I once managed to obtain the fet.exe like that, but it didn't run under Windows, it complained about missing .dll-s. Also, installation of cross-compile mingw32 under GNU/Linux is difficult, and you need to change some things, and compilation is also difficult.

Andrés Chandía

@ch

Andrés Chandía

#9
I haven't done it jet, but now I'm comming back to this isue....

QuoteThis can be implemented easily in FET, I can tell you where (in src/engine/rules.cpp, function read (line 5133) and function write (line 7019), maybe alternatively in src/interface/fetmainform.cpp, function on_fileOpenAction_activated (line 784) and function fileSaveAs (line 866)).

Edited to add: and function fileSave (fetmainform.cpp, line 1284).

Sorry for my ignorance, but what should I write or change at all of those lines from the files you've mentioned?
@ch

Andrés Chandía

#10
Another stuff, I couldn't download the version you recommend of QT, because the link to older versions didn't work at qt.nokia page, do you have it, is it possible to share it?
@ch

Andrés Chandía

Now is working the old stuff link, but anyway I still don't know how to proceed with the files, I mean what to edit (add, delete, change) at the mentioned lines.

Thanks
@ch

Liviu Lalescu

Do you know C++ or have somebody who knows C++? It should be easy for such a person. And a bit of Qt (very little).

You can test if a file exists in Qt:


QFile::exists("file.ext");


You can create a file in Qt:


QFile file("file.ext");
file.open(QIODevice::WriteOnly);
file.close();


You can remove a file in Qt:


QFile::remove("file.ext");


Maybe you need to add this include:


#include <QFile>


Andrés Chandía

So, you mean that is not a matter of just editing some stuff, are functions to be created (programmed)?
Sorry, but can you indicate what are you pointing to with the Qt commands you've sent me, I'm not a programmer, that's why is difficult for me to understand easily what you intend to make me be aware of.
@ch

Liviu Lalescu

#14
QuoteSo, you mean that is not a matter of just editing some stuff, are functions to be created (programmed)?
Sorry, but can you indicate what are you pointing to with the Qt commands you've sent me, I'm not a programmer, that's why is difficult for me to understand easily what you intend to make me be aware of.

I'll try to make you a file to use, but it is a bit difficult, as I am not at your place, to check the code in your environment, so it may not work.

I'll post here the modified file in a short time.