00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef AEGIS_USER_H
00021 #define AEGIS_USER_H
00022
00023 #include <common/ac/shared_ptr.h>
00024
00025 #include <common/nstring.h>
00026 #include <libaegis/output.h>
00027 #include <libaegis/uconf.h>
00028 #include <libaegis/ustate.h>
00029
00030 class project_ty;
00031 class output_ty;
00032
00037 class user_ty
00038 {
00039 public:
00045 typedef aegis_shared_ptr<user_ty> pointer;
00046
00052 ~user_ty();
00053
00059 static user_ty::pointer create();
00060
00061 private:
00065 user_ty();
00066
00067 public:
00075 static user_ty::pointer create(int uid);
00076
00077 private:
00084 user_ty(int uid);
00085
00086 public:
00097 static user_ty::pointer create(int uid, int gid);
00098
00099 private:
00108 user_ty(int uid, int gid);
00109
00110 public:
00123 static user_ty::pointer create(const nstring &login_name);
00124
00134 static user_ty::pointer create_by_directory(const nstring &path);
00135
00145 static void progress_option_set(void (*usage)(void));
00146
00156 static void progress_option_clear(void (*usage)(void));
00157
00171 bool progress_get();
00172
00176 nstring name() const;
00177
00182 nstring full_name() const;
00183
00194 static nstring full_name(const nstring &login);
00195
00200 int get_uid() const;
00201
00206 bool check_uid() const;
00207
00212 int get_gid() const;
00213
00218 bool check_gid() const;
00219
00224 nstring get_group_name() const;
00225
00235 void set_gid(int gid, bool weak = false);
00236
00243 void umask_set(int um);
00244
00249 int umask_get() const;
00250
00255 nstring get_home() const;
00256
00262 nstring get_email_address();
00263
00268 void ustate_write();
00269
00279 void own_add(project_ty *pp, long chanum);
00280
00295 bool own_nth(project_ty *pp, long n, long &chanum);
00296
00307 void own_remove(project_ty *pp, long chanum);
00308
00318 long default_change(project_ty *pp);
00319
00325 nstring default_project();
00326
00338 nstring default_development_directory(project_ty *pp);
00339
00347 nstring default_project_directory();
00348
00355 void become_begin();
00356
00364 void become_end();
00365
00386 class become
00387 {
00388 public:
00392 become(user_ty::pointer a_up) :
00393 up(a_up)
00394 {
00395 up->become_begin();
00396 }
00397
00401 ~become()
00402 {
00403 up->become_end();
00404 }
00405
00406 private:
00411 user_ty::pointer up;
00412
00416 become(const become &);
00417
00421 become &operator=(const become &);
00422 };
00423
00438 bool delete_file_query(const nstring &filename, bool isdir,
00439 int default_preference);
00440
00448 static void delete_file_argument(void (*usage)(void));
00449
00454 void ustate_lock_prepare();
00455
00463 static void lock_wait_argument(void(*usage)(void));
00464
00469 bool lock_wait();
00470
00476 nstring editor_command();
00477
00484 nstring visual_command();
00485
00494 uconf_diff_preference_ty diff_preference();
00495
00503 bool pager_preference();
00504
00510 nstring pager_command();
00511
00519 bool persevere_preference(bool dflt);
00520
00528 static void persevere_argument(void(*usage)(void));
00529
00540 uconf_log_file_preference_ty log_file_preference(
00541 uconf_log_file_preference_ty dflt);
00542
00551 static void relative_filename_preference_argument(void(*usage)(void));
00552
00565 uconf_relative_filename_preference_ty relative_filename_preference(
00566 uconf_relative_filename_preference_ty dflt);
00567
00575 static void symlink_pref_argument(void(*usage)(void));
00576
00590 bool symlink_pref(bool proj_files_changed);
00591
00599 static void whiteout_argument(void(*)(void));
00600
00612 bool whiteout(int dflt = -1);
00613
00621 void uconf_write_xml(output::pointer op);
00622
00634 uconf_ty *uconf_get();
00635
00636 private:
00641 nstring login_name;
00642
00647 nstring login_full_name;
00648
00653 nstring home;
00654
00659 nstring group_name;
00660
00665 int user_id;
00666
00671 int group_id;
00672
00677 int umask;
00678
00686 nstring ustate_path;
00687
00695 ustate_ty *ustate_data;
00696
00701 bool ustate_is_new;
00702
00708 bool ustate_modified;
00709
00717 ustate_ty *ustate_get(project_ty *pp);
00718
00723 nstring uconf_path;
00724
00730 uconf_ty *uconf_data;
00731
00737 long lock_magic;
00738
00743 void lock_sync();
00744
00749 static size_t pool_nusers;
00750
00757 static size_t pool_nusers_max;
00758
00766 static pointer *pool_user;
00767
00782 static user_ty::pointer pool_find(int uid);
00783
00788 static void pool_add(user_ty::pointer up);
00789
00794 void waiting_for_lock();
00795
00800 static void waiting_for_lock(void *);
00801 };
00802
00803
00804
00805 user_ty::pointer user_numeric(int uid) DEPRECATED;
00806
00807
00808 user_ty::pointer user_numeric2(int uid, int gid) DEPRECATED;
00809
00810
00811 user_ty::pointer user_symbolic(string_ty *login_name) DEPRECATED;
00812
00813
00814 user_ty::pointer user_executing(void) DEPRECATED;
00815
00816
00817 void user_free(user_ty::pointer) DEPRECATED;
00818
00819
00820 user_ty::pointer user_copy(user_ty::pointer) DEPRECATED;
00821
00822
00823 string_ty *user_name(user_ty::pointer up) DEPRECATED;
00824
00825
00826 string_ty *user_name2(user_ty::pointer up) DEPRECATED;
00827
00828
00829 int user_id(user_ty::pointer) DEPRECATED;
00830
00831
00832 int user_gid(user_ty::pointer) DEPRECATED;
00833
00834
00835 int user_umask(user_ty::pointer) DEPRECATED;
00836
00837
00838 void user_ustate_lock_prepare(user_ty::pointer) DEPRECATED;
00839
00840
00841 string_ty *user_group(user_ty::pointer) DEPRECATED;
00842
00843
00844 string_ty *user_home(user_ty::pointer up) DEPRECATED;
00845
00846
00847 string_ty *user_email_address(user_ty::pointer up) DEPRECATED;
00848
00849
00850 string_ty *user_editor_command(user_ty::pointer) DEPRECATED;
00851
00852
00853 string_ty *user_visual_command(user_ty::pointer) DEPRECATED;
00854
00855
00856 string_ty *user_pager_command(user_ty::pointer) DEPRECATED;
00857
00858
00859 string_ty *user_full_name(string_ty *) DEPRECATED;
00860
00861
00862 void user_ustate_write(user_ty::pointer) DEPRECATED;
00863
00864
00865 void user_own_add(user_ty::pointer up, project_ty *pp, long chanum) DEPRECATED;
00866
00867
00868 int user_own_nth(user_ty::pointer up, project_ty *oo, long n, long *chanum_p)
00869 DEPRECATED;
00870
00871
00872 void user_own_remove(user_ty::pointer up, project_ty *pp, long chanum)
00873 DEPRECATED;
00874
00875
00876 long user_default_change(user_ty::pointer up, project_ty *pp) DEPRECATED;
00877
00878
00879 string_ty *user_default_project_by_user(user_ty::pointer) DEPRECATED;
00880
00881
00882 string_ty *user_default_project(void) DEPRECATED;
00883
00884
00885 string_ty *user_default_development_directory(user_ty::pointer up,
00886 project_ty *pp) DEPRECATED;
00887
00888
00889 string_ty *user_default_project_directory(user_ty::pointer) DEPRECATED;
00890
00891
00892 void user_become(user_ty::pointer) DEPRECATED;
00893
00894
00895 void user_become_undo(void) DEPRECATED;
00896
00897
00898 bool user_delete_file_query(user_ty::pointer up, string_ty *filename,
00899 bool isdir, int default_preference) DEPRECATED;
00900
00901
00902 void user_delete_file_argument(void (*)(void)) DEPRECATED;
00903
00904
00905 int user_diff_preference(user_ty::pointer) DEPRECATED;
00906
00907
00908 int user_pager_preference(user_ty::pointer) DEPRECATED;
00909
00910
00911 int user_persevere_preference(user_ty::pointer, int) DEPRECATED;
00912
00913
00914 void user_persevere_argument(void(*)(void)) DEPRECATED;
00915
00916
00917 uconf_log_file_preference_ty user_log_file_preference(user_ty::pointer,
00918 uconf_log_file_preference_ty) DEPRECATED;
00919
00920
00921 void user_lock_wait_argument(void(*usage)(void)) DEPRECATED;
00922
00923
00924 int user_lock_wait(user_ty::pointer up) DEPRECATED;
00925
00926
00927 void user_whiteout_argument(void(*)(void)) DEPRECATED;
00928
00929
00930 int user_whiteout(user_ty::pointer up, int dflt = -1) DEPRECATED;
00931
00932
00933 void user_symlink_pref_argument(void(*)(void)) DEPRECATED;
00934
00935
00936 int user_symlink_pref(user_ty::pointer, int) DEPRECATED;
00937
00938
00939 void user_relative_filename_preference_argument(void(*)(void)) DEPRECATED;
00940
00941
00942 uconf_relative_filename_preference_ty user_relative_filename_preference(
00943 user_ty::pointer, uconf_relative_filename_preference_ty) DEPRECATED;
00944
00945
00946 void user_uconf_write_xml(user_ty::pointer, output::pointer) DEPRECATED;
00947
00948
00949 uconf_ty *user_uconf_get(user_ty::pointer) DEPRECATED;
00950
00951 #endif // AEGIS_USER_H