MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / getUsername

Method getUsername

global.cpp:778–810  ·  view source on GitHub ↗

Get the username from the system

Source from the content-addressed store, hash-verified

776
777// Get the username from the system
778QString Global::getUsername() {
779
780 if (!autosetUsername())
781 return "";
782
783 // First, see if the Evernote user record is available
784 UserTable userTable(db);
785 User user;
786 userTable.getUser(user);
787 if (user.name.isSet())
788 return user.name;
789// Windows Check
790#ifndef _WIN32
791 register struct passwd *pw;
792 register uid_t uid;
793 QString username="";
794
795 uid = geteuid();
796 pw = getpwuid(uid);
797 if (pw) {
798 username = pw->pw_gecos;
799 username.remove(QChar(','));
800 if (username != "")
801 return username.trimmed();
802 username = pw->pw_name;
803 return username.trimmed();
804 }
805#else
806 return qgetenv("USERNAME");
807#endif // End Windows Check
808
809 return "";
810}
811
812
813// Determine if we should automatically set the username on new notes

Callers 1

DatabaseConnectionMethod · 0.80

Calls 3

removeMethod · 0.80
getUserMethod · 0.45
isSetMethod · 0.45

Tested by

no test coverage detected