id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,538,499
|
ResSolution.h
|
Stazed_rakarrack-plus/src/FX/ResSolution.h
|
/*
rakarrack - Audio effects software
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* File: ResSolution.h
* Author: sspresto
*
* Created on June 24, 2024, 4:26 PM
*/
#ifndef RESSOLUTION_H
#define RESSOLUTION_H
#include "APhaser.h"
#define RESSOLLV2_URI "https://github.com/Stazed/rakarrack-plus#ressol"
#define RESSOL_NAME "RakarrackPlus ResSolution"
const int C_RESSOL_PARAMETERS = 13;
enum Ressol_Index
{
Ressol_DryWet = 0,
Ressol_Distortion,
Ressol_LFO_Tempo, // Label is 'Shift' for ResSolution
Ressol_LFO_Random, // Not used here
Ressol_LFO_Type, // Fixed to static
Ressol_LFO_Stereo,
Ressol_Width,
Ressol_Feedback,
Ressol_Stages,
Ressol_Mismatch,
Ressol_Subtract,
Ressol_Depth,
Ressol_Hyper
};
static const char *ressol_parameters[] =
{
strdup(NTS(Ressol_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Ressol_Distortion).c_str()), "Distort", "DISTORT",
strdup(NTS(Ressol_LFO_Tempo).c_str()), "Shift", "SHIFT",
strdup(NTS(Ressol_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(Ressol_Width).c_str()), "Width", "WIDTH",
strdup(NTS(Ressol_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Ressol_Stages).c_str()), "Stages", "STAGES",
strdup(NTS(Ressol_Mismatch).c_str()), "Mismatch", "MISMATCH",
strdup(NTS(Ressol_Subtract).c_str()), "Subtract", "SUB",
strdup(NTS(Ressol_Depth).c_str()), "Phase Depth", "DEPTH",
strdup(NTS(Ressol_Hyper).c_str()), "Hyper", "HYPER"
};
class ResSolution :public Analog_Phaser
{
public:
ResSolution (double sample_rate, uint32_t intermediate_bufsize);
void setpreset (int npreset);
void changepar (int npar, int value);
int get_number_efx_parameters () {return C_RESSOL_PARAMETERS;};
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return RESSOLLV2_URI; };
virtual std::string get_name(int) {return RESSOL_NAME; };
private:
};
#endif /* RESSOLUTION_H */
| 2,655
|
C++
|
.h
| 68
| 35.382353
| 79
| 0.70144
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,500
|
MusicDelay.h
|
Stazed_rakarrack-plus/src/FX/MusicDelay.h
|
/*
ZynAddSubFX - a software synthesizer
Echo.h - Echo Effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MUSDELAY_H
#define MUSDELAY_H
#include "Effect.h"
#define MDELLV2_URI "https://github.com/Stazed/rakarrack-plus#delm"
#define MDEL_NAME "RakarrackPlus Musical Delay"
const int C_MUSIC_PARAMETERS = 13;
enum Music_Index
{
Music_DryWet = 0,
Music_Pan_1,
Music_Delay_1,
Music_Del_Offset,
Music_LR_Cross,
Music_Feedback_1,
Music_Damp,
Music_Pan_2,
Music_Delay_2,
Music_Feedback_2,
Music_Tempo,
Music_Gain_1,
Music_Gain_2
};
static const char *mdel_parameters[] =
{
strdup(NTS(Music_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Music_Pan_1).c_str()), "Panning 1", "PAN1",
strdup(NTS(Music_Delay_1).c_str()), "Delay 1", "DEL1",
strdup(NTS(Music_Del_Offset).c_str()), "Delay Offset", "OFFS",
strdup(NTS(Music_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(Music_Feedback_1).c_str()), "Feedback 1", "FB1",
strdup(NTS(Music_Damp).c_str()), "Damping", "DAMP",
strdup(NTS(Music_Pan_2).c_str()), "Panning 2", "PAN2",
strdup(NTS(Music_Delay_2).c_str()), "Delay 2", "DEL2",
strdup(NTS(Music_Feedback_2).c_str()), "Feedback 2", "FB2",
strdup(NTS(Music_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Music_Gain_1).c_str()), "Gain 1", "GAIN1",
strdup(NTS(Music_Gain_2).c_str()), "Gain 2", "GAIN2"
};
class MusicDelay : public Effect
{
public:
MusicDelay (double sample_rate, uint32_t intermediate_bufsize);
~MusicDelay ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_MUSIC_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return MDELLV2_URI; };
virtual std::string get_name(int) {return MDEL_NAME; };
private:
void setvolume (int _Pvolume);
void setpanning (int num, int _Ppanning);
void setdelay (int num, int _Pdelay);
void setgain (int num, int _Pgain);
void setlrdelay (int _Plrdelay);
void setlrcross (int _Plrcross);
void setfb (int num, int _Pfb);
void sethidamp (int _Phidamp);
void settempo (int _Ptempo);
void initdelays ();
uint32_t PERIOD;
float fSAMPLE_RATE;
//Parametrii
int Pvolume; //Volumul or E/R
int Ppanning1; //Panning
int Ppanning2;
int Pgain1;
int Pgain2;
int Pdelay1;
int Pdelay2;
int Plrdelay; // L/R delay difference
int Plrcross; // L/R Mixing
int Pfb1; //Feed-back-ul
int Pfb2;
int Phidamp;
int Ptempo;
//Parametrii reali
int maxx_delay;
int dl1, dr1, dl2, dr2, delay1, delay2, lrdelay;
int kl1, kr1, kl2, kr2;
float panning1, panning2, lrcross, fb1, fb2, hidamp;
float gain1, gain2;
float *ldelay1, *rdelay1, *ldelay2, *rdelay2;
float oldl1, oldr1, oldl2, oldr2; //pt. lpf
};
#endif
| 3,928
|
C++
|
.h
| 110
| 31.472727
| 79
| 0.679747
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,501
|
Opticaltrem.h
|
Stazed_rakarrack-plus/src/FX/Opticaltrem.h
|
/*
rakarrack - a guitar effects software
Opticaltrem.h - Opticaltrem Effect definitions
Copyright (C) 2008-2010 Ryan Billing
Author: Josep Andreu & Ryan Billing
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef Opticaltrem_H
#define Opticaltrem_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#define OPTTREMLV2_URI "https://github.com/Stazed/rakarrack-plus#Otrem"
#define OPTTREM_NAME "RakarrackPlus OpticalTrem"
const int C_OPTICAL_PARAMETERS = 7;
enum Optical_Index
{
Optical_Depth = 0,
Optical_LFO_Tempo,
Optical_LFO_Random,
Optical_LFO_Type,
Optical_LFO_Stereo,
Optical_Pan,
Optical_Invert
};
static const char *optical_parameters[] =
{
strdup(NTS(Optical_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(Optical_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Optical_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(Optical_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(Optical_LFO_Stereo).c_str()), "LFO L/R Delay", "STDF",
strdup(NTS(Optical_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Optical_Invert).c_str()), "Invert", "INV"
};
class Opticaltrem : public Effect
{
public:
Opticaltrem (double sample_rate, uint32_t intermediate_bufsize);
~Opticaltrem ();
void out (float * efxoutl, float * efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpanning(int value);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_OPTICAL_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return OPTTREMLV2_URI; };
virtual std::string get_name(int) {return OPTTREM_NAME; };
private:
float cSAMPLE_RATE;
uint32_t PERIOD;
int Pdepth;
int Ppanning;
int Pinvert; //Invert the opto and resistor relationship
float Ra, Rb, R1, Rp, b, dTC, dRCl, dRCr, minTC, alphal, alphar, stepl, stepr, oldstepl, oldstepr, fdepth;
float lstep,rstep;
float cperiod;
float gl, oldgl;
float gr, oldgr;
float rpanning, lpanning;
EffectLFO* lfo;
};
#endif
| 3,014
|
C++
|
.h
| 80
| 33.8125
| 110
| 0.715713
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,502
|
VaryBand.h
|
Stazed_rakarrack-plus/src/FX/VaryBand.h
|
/*
VaryBand.h - Distorsion Effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
ZynAddSubFX - a software synthesizer
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Renamed from MBVvol.h 4/18/2020 by stazed
#ifndef VARYBAND_H
#define VARYBAND_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#include "../EFX_common/AnalogFilter.h"
#define VARYBANDLV2_URI "https://github.com/Stazed/rakarrack-plus#VaryBand"
#define VARY_NAME "RakarrackPlus VaryBand"
/**
* This is the Rakarrack-plus parameters number for presets and file saving
* which does not use last four listed
*/
const int C_VARYBAND_PARAMETERS = 11;
enum VaryBand_Index
{
VaryBand_DryWet = 0,
VaryBand_LFO_Tempo_1,
VaryBand_LFO_Type_1,
VaryBand_LFO_Stereo_1,
VaryBand_LFO_Tempo_2,
VaryBand_LFO_Type_2,
VaryBand_LFO_Stereo_2,
VaryBand_Cross_1,
VaryBand_Cross_2,
VaryBand_Cross_3,
VaryBand_Combination, // Pcombi legacy
VaryBand_Low_Band,
VaryBand_Mid_Band_1,
VaryBand_Mid_Band_2,
VaryBand_High_Band
};
static const char *vary_parameters[] =
{
strdup(NTS(VaryBand_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(VaryBand_LFO_Tempo_1).c_str()), "Tempo 1", "TEMPO1",
strdup(NTS(VaryBand_LFO_Type_1).c_str()), "LFO Type 1", "TYPE1",
strdup(NTS(VaryBand_LFO_Stereo_1).c_str()), "LFO L/R Delay 1", "STDL1",
strdup(NTS(VaryBand_LFO_Tempo_2).c_str()), "Tempo 2", "TEMPO2",
strdup(NTS(VaryBand_LFO_Type_2).c_str()), "LFO Type 2", "TYPE2",
strdup(NTS(VaryBand_LFO_Stereo_2).c_str()), "LFO L/R Delay 2", "STDL2",
strdup(NTS(VaryBand_Cross_1).c_str()), "Low/Mid1 Crossover", "LMCR",
strdup(NTS(VaryBand_Cross_2).c_str()), "Mid1/Mid2 Crossover", "MMCR",
strdup(NTS(VaryBand_Cross_3).c_str()), "Mid2/High Crossover", "MHCR",
strdup(NTS(VaryBand_Low_Band).c_str()), "Low Band Volume", "LB",
strdup(NTS(VaryBand_Mid_Band_1).c_str()), "Mid Band 1 Volume", "M1B",
strdup(NTS(VaryBand_Mid_Band_2).c_str()), "Mid Band 2 Volume", "M2B",
strdup(NTS(VaryBand_High_Band).c_str()), "High Band Volume", "HB"
};
class VaryBand : public Effect
{
public:
VaryBand (double sample_rate, uint32_t intermediate_bufsize);
~VaryBand ();
void out (float *efxoutl, float *efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_VARYBAND_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return VARYBANDLV2_URI; };
virtual std::string get_name(int) {return VARY_NAME; };
void initialize ();
void clear_initialize();
private:
uint32_t PERIOD;
double fSAMPLE_RATE;
float *lowl;
float *lowr;
float *midll;
float *midlr;
float *midhl;
float *midhr;
float *highl;
float *highr;
void setvolume (int Pvolume);
void setpanning (int Ppanning);
void setCross1 (int value);
void setCross2 (int value);
void setCross3 (int value);
void setCombi (int value);
void calcCombi ();
void parseCombi (int value);
void updateVols(void);
void setSource(float **ptr, float **ptrr, int val);
//Parametrii
int Pvolume; //Volumul or E/R
int Pcombi;
int Cross1;
int Cross2;
int Cross3;
int PsL, PsML, PsMH, PsH;//volume source per band
//Parametrii reali
float lfo1l,lfo1r,lfo2l,lfo2r;
float v1l,v1r,v2l,v2r;
float d1,d2,d3,d4;
float volL,volML,volMH,volH;
float volLr,volMLr,volMHr,volHr;
float *sourceL,*sourceML,*sourceMH,*sourceH;
float *sourceLr,*sourceMLr,*sourceMHr,*sourceHr;
float one, zero;
AnalogFilter *lpf1l, *lpf1r, *hpf1l, *hpf1r;
AnalogFilter *lpf2l, *lpf2r, *hpf2l, *hpf2r;
AnalogFilter *lpf3l, *lpf3r, *hpf3l, *hpf3r;
float *interpbuf; //buffer for filters
EffectLFO *lfo1,*lfo2;
};
#endif
| 4,786
|
C++
|
.h
| 129
| 32.821705
| 79
| 0.693789
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,503
|
Convolotron.h
|
Stazed_rakarrack-plus/src/FX/Convolotron.h
|
/*
Convolotron.h - Convolotron Effect
Author: Ryam Billing & Jospe Andreu
Adapted effect structure of ZynAddSubFX - a software synthesizer
Author: Nasca Octavian Paul
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef CONVOLOTRON_H
#define CONVOLOTRON_H
#include <sndfile.h>
#include <vector>
#include "Effect.h"
#include "../EFX_common/Resample.h"
#include "../EFX_common/mayer_fft.h"
#define CONVOLOTRONLV2_URI "https://github.com/Stazed/rakarrack-plus#Convolotron"
#define CONVOLOTRON_NAME "RakarrackPlus Convolotron"
const int C_CONVO_PARAMETERS = 11;
enum Convo_Index
{
Convo_DryWet = 0,
Convo_Pan,
Convo_Safe,
Convo_Length,
Convo_User_File,
Convo_SKIP_5,
Convo_Damp,
Convo_Level,
Convo_Set_File,
Convo_SKIP_9,
Convo_Feedback
};
static const char *convo_parameters[] =
{
strdup(NTS(Convo_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Convo_Pan).c_str()), "Pan", "PAN",
strdup(NTS(Convo_Safe).c_str()), "Safe", "SAFE",
strdup(NTS(Convo_Length).c_str()), "Length", "LENGTH",
strdup(NTS(Convo_Damp).c_str()), "Dampening", "DAMP",
strdup(NTS(Convo_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Convo_Feedback).c_str()), "Feedback", "FB"
};
class Convolotron :public Effect
{
public:
Convolotron (int DS, int uq, int dq, double sample_rate, uint16_t intermediate_bufsize);
~Convolotron ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_CONVO_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return CONVOLOTRONLV2_URI; };
virtual std::string get_name(int) {return CONVOLOTRON_NAME; };
void initialize();
void clear_initialize();
int setfile (int value);
void adjust(int DS, uint32_t period);
void loaddefault();
void set_user_files(const std::vector<User_Files> &wav_files){WAV_Files = wav_files;};
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
char Filename[128];
private:
std::vector<User_Files> WAV_Files;
unsigned int SAMPLE_RATE;
float fSAMPLE_RATE;
int nSAMPLE_RATE;
float nfSAMPLE_RATE;
uint32_t PERIOD;
int nPERIOD;
float fPERIOD;
//Parametrii
int Pvolume; //This is master wet/dry mix like other FX...but I am finding it is not useful
int Ppanning; //Panning
int Plrcross; // L/R Mixing // This is a mono effect, so lrcross and panning are pointless
int Phidamp;
int Plevel; //This should only adjust the level of the IR effect, and not wet/dry mix
int Psafe;
int Plength; //5...500 ms// Set maximum length of IR.
int Puser; //-64...64//Feedback.
int Filenum;
int Pfb; //-64 ... 64// amount of feedback
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void sethidamp (int _Phidamp);
void process_rbuf();
void UpdateLength ();
int offset;
int maxx_size,maxx_read,real_len,length;
int DS_state;
double u_up;
double u_down;
float lpanning, rpanning, hidamp, alpha_hidamp, convlength, oldl;
float *rbuf, *buf, *lxn;
float *templ, *tempr;
float level,fb, feedback;
float levpanl,levpanr;
SNDFILE *infile;
SF_INFO sfinfo;
//Parametrii reali
class Resample *M_Resample;
class Resample *U_Resample;
class Resample *D_Resample;
fft_filter impulse;
};
#endif
| 4,373
|
C++
|
.h
| 122
| 31.47541
| 95
| 0.698787
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,504
|
Shifter.h
|
Stazed_rakarrack-plus/src/FX/Shifter.h
|
/*
rakarrack - a guitar effects software
PitchShifter.h - Shifterr definitions
Copyright (C) 2008-2010 Josep Andreu
Author: Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SHIFTER_H
#define SHIFTER_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/smbPitchShift.h"
#include "../EFX_common/Resample.h"
#define SHIFTERLV2_URI "https://github.com/Stazed/rakarrack-plus#Shifter"
#define SHIFTER_NAME "RakarrackPlus Shifter"
#define IDLE 0
#define UP 1
#define WAIT 2
#define DOWN 3
const int C_SHIFTER_PARAMETERS = 10;
enum Shifter_Index
{
Shifter_DryWet = 0,
Shifter_Pan,
Shifter_Gain,
Shifter_Attack,
Shifter_Decay,
Shifter_Threshold,
Shifter_Interval,
Shifter_Shift,
Shifter_Mode,
Shifter_Whammy
};
static const char *shift_parameters[] =
{
strdup(NTS(Shifter_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Shifter_Pan).c_str()), "Pan", "PAN",
strdup(NTS(Shifter_Gain).c_str()), "Gain", "GAIN",
strdup(NTS(Shifter_Attack).c_str()), "Attack", "ATACK",
strdup(NTS(Shifter_Decay).c_str()), "Decay", "DECAY",
strdup(NTS(Shifter_Threshold).c_str()), "Threshold", "THRESH",
strdup(NTS(Shifter_Interval).c_str()), "Interval", "INT",
strdup(NTS(Shifter_Shift).c_str()), "Shift Down", "DN",
strdup(NTS(Shifter_Mode).c_str()), "Mode", "MODE",
strdup(NTS(Shifter_Whammy).c_str()), "Whammy", "WHAMMY"
};
class Shifter : public Effect
{
public:
Shifter (long int Quality, int DS, int uq, int dq, double sample_rate, uint32_t intermediate_bufsize);
~Shifter ();
void out (float *efxoutl, float *efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar(int npar);
void cleanup();
int get_number_efx_parameters () {return C_SHIFTER_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return SHIFTERLV2_URI; };
virtual std::string get_name(int) {return SHIFTER_NAME; };
void initialize();
void clear_initialize();
void applyfilters (float * efxoutl);
void adjust(int DS, double sample_rate);
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
long int hq;
float *outi;
float *outo;
private:
void setvolume (int Pvolume);
void setpanning (int Ppan);
void setinterval (int Pinterval);
void setgain (int Pgain);
int DS_state;
uint32_t PERIOD;
double fSAMPLE_RATE;
int Pvolume;
int Pgain;
int Ppan;
int Pinterval;
int Pupdown;
int Pmode;
int Pattack;
int Pdecay;
int Pthreshold;
int Pwhammy;
int state;
int nPERIOD;
int nSAMPLE_RATE;
float nRATIO;
long window;
double u_up;
double u_down;
float nfSAMPLE_RATE;
float env, t_level, td_level, tz_level;
float a_rate,d_rate,tune, range, whammy;
float panning;
float gain;
float interval;
float *templ, *tempr;
Resample *U_Resample;
Resample *D_Resample;
PitchShifter *PS;
};
#endif
| 3,874
|
C++
|
.h
| 121
| 27.933884
| 106
| 0.697337
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,505
|
Phaser.h
|
Stazed_rakarrack-plus/src/FX/Phaser.h
|
/*
ZynAddSubFX - a software synthesizer
Phaser.h - Phaser effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PHASER_H
#define PHASER_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#define PHASELV2_URI "https://github.com/Stazed/rakarrack-plus#phas"
#define PHASE_NAME "RakarrackPlus Phaser"
const int C_PHASER_PARAMETERS = 12;
enum Phaser_Index
{
Phaser_DryWet = 0,
Phaser_Pan,
Phaser_LFO_Tempo,
Phaser_LFO_Random,
Phaser_LFO_Type,
Phaser_LFO_Stereo,
Phaser_Depth,
Phaser_Feedback,
Phaser_Stages,
Phaser_LR_Cross,
Phaser_Subtract,
Phaser_Phase
};
static const char *phase_parameters[] =
{
strdup(NTS(Phaser_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Phaser_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Phaser_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Phaser_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(Phaser_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(Phaser_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(Phaser_Depth).c_str()), "Phase Depth", "DEPTH",
strdup(NTS(Phaser_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Phaser_Stages).c_str()), "Stages", "STAGES",
strdup(NTS(Phaser_LR_Cross).c_str()), "Left/Right Crossover", "LRCR",
strdup(NTS(Phaser_Subtract).c_str()), "Subtract", "SUB",
strdup(NTS(Phaser_Phase).c_str()), "Phase", "PHASE"
};
class Phaser : public Effect
{
public:
Phaser (double sample_rate, uint32_t intermediate_bufsize);
~Phaser ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_PHASER_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return PHASELV2_URI; };
virtual std::string get_name(int) {return PHASE_NAME; };
private:
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setdepth (int _Pdepth);
void setfb (int _Pfb);
void setlrcross (int _Plrcross);
void setstages (int _Pstages);
void setphase (int _Pphase);
//Parametrii Phaser
uint32_t PERIOD;
float fPERIOD;
int Pvolume;
int Ppanning;
int Pdepth; //the depth of the Phaser
int Pfb; //feedback
int Plrcross; //feedback
int Pstages;
int Poutsub; //if I wish to substract the output instead of the adding it
int Pphase;
//Control Parametrii
//Valorile interne
float panning, fb, depth, lrcross, fbl, fbr, phase;
float *oldl, *oldr;
float oldlgain, oldrgain;
EffectLFO *lfo; //Phaser modulator
};
#endif
| 3,618
|
C++
|
.h
| 99
| 32.393939
| 79
| 0.695104
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,506
|
CoilCrafter.h
|
Stazed_rakarrack-plus/src/FX/CoilCrafter.h
|
/*
Rakarrack Audio FX software
CoilCrafter.h - Pick Up Emulation
Using RBFilter
Using Steve Harris LADSPA Plugin harmonic_gen
Modified for rakarrack by Ryan Billing & Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef COILCRAFTER_H
#define COILCRAFTER_H
#include "Effect.h"
#include "../EFX_common/HarmonicEnhancer.h"
#include "../EFX_common/AnalogFilter.h"
#define COILLV2_URI "https://github.com/Stazed/rakarrack-plus#CoilCrafter"
#define COIL_NAME "RakarrackPlus Coil Crafter"
const int C_COIL_PARAMETERS = 9;
enum Coil_Index
{
Coil_Gain = 0,
Coil_Origin,
Coil_Destiny,
Coil_Freq_1,
Coil_Q_1,
Coil_Freq_2,
Coil_Q_2,
Coil_Tone,
Coil_NeckMode
};
static const char *coil_parameters[] =
{
strdup(NTS(Coil_Gain).c_str()), "Gain", "GAIN",
strdup(NTS(Coil_Freq_1).c_str()), "Origin Pickup Frequency", "F1",
strdup(NTS(Coil_Q_1).c_str()), "Origin Pickup Resonance", "Q1",
strdup(NTS(Coil_Freq_2).c_str()), "Destination Pickup Frequency", "F2",
strdup(NTS(Coil_Q_2).c_str()), "Destination Pickup Resonance", "Q2",
strdup(NTS(Coil_Tone).c_str()), "Tone", "TONE",
strdup(NTS(Coil_NeckMode).c_str()), "Neck Pickup", "MODE"
};
class CoilCrafter : public Effect
{
public:
CoilCrafter (double sample_rate, uint32_t intermediate_bufsize);
~CoilCrafter ();
void out (float * efxoutl, float * efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_COIL_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return COILLV2_URI; };
virtual std::string get_name(int) {return COIL_NAME; };
private:
uint32_t PERIOD;
void setvolume (int value);
void sethpf (int value);
void setfreq1();
void setfreq2();
void setq1();
void setq2();
int Pvolume;
int Ppo;
int Ppd;
int Ptone;
int Pq1;
int Pfreq1;
int Pq2;
int Pfreq2;
int Pmode;
float tfreqs[10];
float tqs[10];
float rm[10];
float freq1,q1,freq2,q2;
float att;
class HarmEnhancer *harm;
class AnalogFilter *RB1l, *RB1r;
class AnalogFilter *RB2l,*RB2r;
float* interpbuf;
};
#endif
| 3,192
|
C++
|
.h
| 95
| 29.505263
| 79
| 0.699153
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,507
|
MuTroMojo.h
|
Stazed_rakarrack-plus/src/FX/MuTroMojo.h
|
/*
ZynAddSubFX - a software synthesizer
MuTroMojo.h - "WahWah" effect and others
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Ryan Billing
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Renamed from RyanWah.h 4/18/2020 by stazed
#ifndef MUTROMOJO_H
#define MUTROMOJO_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#include "../EFX_common/RBFilter.h"
#include "../EFX_common/AnalogFilter.h"
#define MUTROLV2_URI "https://github.com/Stazed/rakarrack-plus#MuTroMojo"
#define MUTRO_NAME "RakarrackPlus MuTroMojo"
/**
* This is the amount for File saving and presets Rakarrack-plus.
* The listed are 20 - less the 2 for LV2.
*/
const int C_MUTRO_PARAMETERS = 18;
enum MuTro_Index
{
MuTro_DryWet = 0,
MuTro_Resonance,
MuTro_LFO_Tempo,
MuTro_LFO_Random,
MuTro_LFO_Type,
MuTro_LFO_Stereo,
MuTro_Depth,
MuTro_Env_Sens,
MuTro_Wah,
MuTro_Env_Smooth,
MuTro_LowPass,
MuTro_BandPass,
MuTro_HighPass,
MuTro_Stages,
MuTro_Range,
MuTro_St_Freq,
MuTro_Mod_Res,
Mutro_Mode_Legacy // Rakarrack-plus only
//#ifdef LV2_SUPPORT
,MuTro_AG_Mode,
MuTro_Exp_Wah
//#endif
};
static const char *mutro_parameters[] =
{
strdup(NTS(MuTro_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(MuTro_Resonance).c_str()), "Resonance", "Q",
strdup(NTS(MuTro_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(MuTro_LFO_Random).c_str()), "LFO Randomness", "RND",
strdup(NTS(MuTro_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(MuTro_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(MuTro_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(MuTro_Env_Sens).c_str()), "Envelope Sensitivity", "SENSE",
strdup(NTS(MuTro_Wah).c_str()), "Wah", "WAH",
strdup(NTS(MuTro_Env_Smooth).c_str()), "Envelope Smoothing", "SMOOTH",
strdup(NTS(MuTro_LowPass).c_str()), "Lowpass Level", "LP",
strdup(NTS(MuTro_BandPass).c_str()), "Bandpass Level", "BP",
strdup(NTS(MuTro_HighPass).c_str()), "Highpass Level", "HP",
strdup(NTS(MuTro_Stages).c_str()), "Filter Stages", "STAGES",
strdup(NTS(MuTro_Range).c_str()), "Sweep Range", "RANGE",
strdup(NTS(MuTro_St_Freq).c_str()), "Starting Frequency", "MINFREQ",
strdup(NTS(MuTro_Mod_Res).c_str()), "Modulate Resonance", "VARIQ",
strdup(NTS(MuTro_AG_Mode).c_str()), "Analog Gain Mode", "QMODE",
strdup(NTS(MuTro_Exp_Wah).c_str()), "Exponential Wah", "AMODE"
};
class MuTroMojo : public Effect
{
public:
MuTroMojo (double sample_rate, uint32_t intermediate_bufsize);
~MuTroMojo ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_MUTRO_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return MUTROLV2_URI; };
virtual std::string get_name(int) {return MUTRO_NAME; };
void initialize();
void clear_initialize();
int Pmode;
private:
void setvolume (int _Pvolume);
void setwidth (int _Pwidth);
void setampsns (int _Pampsns);
void reinitfilter ();
float fSAMPLE_RATE;
uint32_t PERIOD;
int Pvolume; //For wet/dry mix
int Pwidth; //0/127// The width of the lfo of the MuTroMojo
int Pampsns; //0/127//how the filter varies according to the input amplitude
int Pampsnsinv; //-64/64//bias of the filter
int Pampsmooth; //0/127//how smooth the input amplitude changes the filter, also for Pampsinsinv smoothing for wah wah pedal
int Prange; //10/6000Hz//how far filter can deviate.
int Php; //-64/64//high pass filter mix
int Plp; //-64/64//low pass filter mix
int Pbp; //-64/64//Bandpass filter mix
int Pq; //0/127//filter resonance.
int Pqm; //Qmode
int Pstages; //0-6// counter// Filter stages
int Pminfreq; //30/800//set lowest freq in range.
int Pamode; //0 or 1// modulation mode.
int variq; //on-off//checkbox//Selects whether Q is varied w/ frequency to emulate a wahwah
//Control Parametrii
int Ftype;
int Fstages;
//Valorile interne
float rpanning, lpanning, depth, ampsns, ampsmooth, wahsmooth, fbias, oldfbias, oldfbias1, oldfbias2, q, frequency, maxfreq, base, ibase, minfreq;
float ms1, lpmix, hpmix, bpmix; //mean squares
float centfreq; //testing
class RBFilter *filterl, *filterr;
class AnalogFilter *sidechain_filter;
float* interpbuf; //buffer for filters
EffectLFO *lfo; //lfo-ul MuTroMojo
};
#endif
| 5,457
|
C++
|
.h
| 134
| 36.514925
| 150
| 0.687701
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,508
|
Expander.h
|
Stazed_rakarrack-plus/src/FX/Expander.h
|
// Based in gate_1410.c LADSPA Swh-plugins
/*
rakarrack - a guitar effects software
Expander.h - Noise Gate Effect definitions
Based on artscompressor.cc by Matthias Kretz <kretz@kde.org>
Stefan Westerfeld <stefan@space.twc.de>
Copyright (C) 2008-2010 Ryan Billing & Josep Andreu
Author: Ryan Billing & Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EXPANDER_H
#define EXPANDER_H
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#define EXPANDLV2_URI "https://github.com/Stazed/rakarrack-plus#Expander"
#define EXPAND_NAME "RakarrackPlus Expander"
const int C_EXPANDER_PARAMETERS = 7;
enum Expander_Index
{
Expander_Threshold = 0,
Expander_Shape,
Expander_Attack,
Expander_Release,
Expander_LPF,
Expander_HPF,
Expander_Gain
};
static const char *expand_parameters[] =
{
strdup(NTS(Expander_Threshold).c_str()), "Threshold", "THRESHOLD",
strdup(NTS(Expander_Shape).c_str()), "Shape", "SHAPE",
strdup(NTS(Expander_Attack).c_str()), "Attack Time", "ATTACK",
strdup(NTS(Expander_Release).c_str()), "Release Time", "RELEASE",
strdup(NTS(Expander_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(Expander_HPF).c_str()), "Highpass Filter", "HPF",
strdup(NTS(Expander_Gain).c_str()), "Output Gain", "OUTPUT"
};
class Expander : public Effect
{
public:
Expander (double sample_rate, uint32_t intermediate_bufsize);
~Expander ();
void out (float * efxoutl, float * efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_EXPANDER_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return EXPANDLV2_URI; };
virtual std::string get_name(int) {return EXPAND_NAME; };
void initialize();
void clear_initialize();
private:
// Compressor
int Pthreshold; // Threshold, -80 to 0dB
int Pattack; // attack time (ms) Set range from 10ms ... 2000ms
int Pdecay; // release time (ms) Set range from 10ms ... 500ms
int Pshape; // Sharpness of transition from off to on. Range is 0 ... 50
int Plpf;
int Phpf;
int Plevel;
int efollower; // This is a mode allowing this object to be used as a "dynamics detector"
// (envelope follower). If efollower == 1, then efxoutl is a level to be used in place of an LFO
// for filter modulation, etc. Then efxoutr is signal + envelope for things such as dynamic distortion.
// Variable efollower is set to 0 by default in constructor. Do not set this mode unless using this object
// to control a parameter with signal dynamics.
void setlpf (int Plpf);
void sethpf (int Phpf);
uint32_t PERIOD;
double fSAMPLE_RATE;
float sgain;
float sfactor;
float tfactor;
float tlevel;
float a_rate;
float d_rate;
float env;
float oldgain;
float gain;
float fs;
float level;
float* interpbuf; //buffer for filters
AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr;
};
#endif
| 3,997
|
C++
|
.h
| 102
| 35.117647
| 111
| 0.710397
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,509
|
Arpie.h
|
Stazed_rakarrack-plus/src/FX/Arpie.h
|
/*
Arpie.h - Echo Effect w/ arpeggiated delay
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
Arpeggiated Echo by Ryan Billing (a.k.a. Transmogrifox)
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ARPIE_H
#define ARPIE_H
#include "Effect.h"
#include "../global.h"
#define ARPIELV2_URI "https://github.com/Stazed/rakarrack-plus#Arpie"
#define ARPIE_NAME "RakarrackPlus Arpie"
const int C_ARPIE_PARAMETERS = 11;
enum Arpie_Index
{
Arpie_DryWet = 0,
Arpie_Pan,
Arpie_Tempo,
Arpie_LR_Delay,
Arpie_LR_Cross,
Arpie_Feedback,
Arpie_Damp,
Arpie_ArpeWD,
Arpie_Harm,
Arpie_Pattern,
Arpie_Subdivision
};
static const char *arpie_parameters[] =
{
strdup(NTS(Arpie_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Arpie_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Arpie_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Arpie_LR_Delay).c_str()), "Left/Right Delay Offset", "LR_DELAY",
strdup(NTS(Arpie_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(Arpie_Feedback).c_str()), "Feedback", "FEEDBACK",
strdup(NTS(Arpie_Damp).c_str()), "Damping", "DAMP",
strdup(NTS(Arpie_ArpeWD).c_str()), "Arpe's Wet/Dry", "ARP",
strdup(NTS(Arpie_Harm).c_str()), "Harmonics", "HARM",
strdup(NTS(Arpie_Pattern).c_str()), "Pattern", "PATTERN",
strdup(NTS(Arpie_Subdivision).c_str()), "Subdivision", "SUBD"
};
class Arpie : public Effect
{
public:
Arpie (double sample_rate, uint32_t intermediate_bufsize);
~Arpie ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_ARPIE_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return ARPIELV2_URI; };
virtual std::string get_name(int) {return ARPIE_NAME; };
private:
float fSAMPLE_RATE;
uint32_t PERIOD;
//Parametrii
int Pvolume; //Volumul or E/R
int Ppanning; //Panning
int Pdelay;
int Plrdelay; // L/R delay difference
int Plrcross; // L/R Mixing
int Pfb; //Feed-back-ul
int Phidamp;
int Preverse;
int Ppattern;
int Pharms;
int Psubdiv;
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setdelay (int _Pdelay);
void setlrdelay (int _Plrdelay);
void setlrcross (int _Plrcross);
void setfb (int _Pfb);
void sethidamp (int _Phidamp);
void setreverse (int _Preverse);
void setpattern (int _Ppattern);
//Parametrii reali
void initdelays ();
int dl, dr, delay, lrdelay;
int kl, kr, rvkl, rvkr, rvfl, rvfr, maxx_delay, fade, harmonic, envcnt, invattack;
int subdiv;
int *pattern;
float panning, lrcross, fb, hidamp, reverse;
float *ldelay, *rdelay;
float oldl, oldr; //pt. lpf
float Srate_Attack_Coeff, envattack, envswell;
};
#endif
| 3,815
|
C++
|
.h
| 106
| 31.641509
| 86
| 0.691301
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,510
|
Flanger.h
|
Stazed_rakarrack-plus/src/FX/Flanger.h
|
/*
ZynAddSubFX - a software synthesizer
Chorus.C - Chorus and Flange effects
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* File: Flanger.h
* Author: sspresto
*
* Created on January 25, 2021, 7:16 PM
*/
#ifndef FLANGER_H
#define FLANGER_H
#include "Chorus.h"
#define FLANGELV2_URI "https://github.com/Stazed/rakarrack-plus#Flange"
#define FLANGE_NAME "RakarrackPlus Flanger"
const int C_FLANGER_PARAMETERS = 13;
enum Flanger_Index
{
Flanger_DryWet = 0,
Flanger_Pan,
Flanger_LFO_Tempo,
Flanger_LFO_Random,
Flanger_LFO_Type,
Flanger_LFO_Stereo,
Flanger_Depth,
Flanger_Delay,
Flanger_Feedback,
Flanger_LR_Cross,
Flanger_SKIP_Flange_10,
Flanger_Subtract,
Flanger_Intense
};
static const char *flange_parameters[] =
{
strdup(NTS(Flanger_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Flanger_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Flanger_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Flanger_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(Flanger_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(Flanger_LFO_Stereo).c_str()), "LFO L/R Delay", "WIDTH",
strdup(NTS(Flanger_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(Flanger_Delay).c_str()), "Delay", "DELAY",
strdup(NTS(Flanger_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Flanger_LR_Cross).c_str()), "Left/Right Crossover", "LRCR",
strdup(NTS(Flanger_Subtract).c_str()), "Subtract", "SUB",
strdup(NTS(Flanger_Intense).c_str()), "Intense", "INTENSE"
};
class Flanger :public Chorus
{
public:
Flanger(double sample_rate, uint32_t intermediate_bufsize);
void setpreset (int npreset);
int get_number_efx_parameters () {return C_FLANGER_PARAMETERS;};
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return FLANGELV2_URI; };
virtual std::string get_name(int) {return FLANGE_NAME; };
private:
};
#endif /* FLANGER_H */
| 2,747
|
C++
|
.h
| 72
| 34.486111
| 79
| 0.707455
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,511
|
Sustainer.h
|
Stazed_rakarrack-plus/src/FX/Sustainer.h
|
/*
Rakarrack Guitar FX
Sustainer.h - Simple compressor/sustainer effect with easy interface, minimal controls
Copyright (C) 2010 Ryan Billing
Author: Ryan Billing
This program is free software; you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SUSTAINER_H
#define SUSTAINER_H
#include "Effect.h"
#define SUSTAINLV2_URI "https://github.com/Stazed/rakarrack-plus#Sustainer"
#define SUSTAIN_NAME "RakarrackPlus Sustainer"
const int C_SUSTAIN_PARAMETERS = 2;
enum Sustain_Index
{
Sustain_Gain = 0,
Sustain_Sustain
};
static const char *sus_parameters[] =
{
strdup(NTS(Sustain_Gain).c_str()), "Gain", "GAIN",
strdup(NTS(Sustain_Sustain).c_str()), "Sustain", "SUS"
};
class Sustainer : public Effect
{
public:
Sustainer (double sample_rate, uint32_t intermediate_bufsize);
~Sustainer ();
void cleanup ();
int get_number_efx_parameters () {return C_SUSTAIN_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return SUSTAINLV2_URI; };
virtual std::string get_name(int) {return SUSTAIN_NAME; };
void out (float * efxoutl, float * efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void changepar (int npar, int value);
int getpar (int npar);
void setpreset (int npreset);
private:
uint32_t PERIOD;
//Parametrii
int Pvolume; //Output Level
int Psustain; //Compression amount
int timer, hold;
float level, fsustain, input,tmpgain;
float prls, compeak, compg, compenv, oldcompenv, calpha, cbeta, cthresh, cratio, cpthresh;
};
#endif
| 2,381
|
C++
|
.h
| 62
| 34.741935
| 94
| 0.735602
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,512
|
Derelict.h
|
Stazed_rakarrack-plus/src/FX/Derelict.h
|
/*
ZynAddSubFX - a software synthesizer
Distorsion.h - Distorsion Effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu & Ryan Billing
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Renamed from NewDist.h on 4/18/2020 by Stazed
#ifndef DERELICT_H
#define DERELICT_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/Waveshaper.h"
#include "../EFX_common/FilterParams.h"
#include "../EFX_common/Filter.h"
#define DERELV2_URI "https://github.com/Stazed/rakarrack-plus#dere"
#define DERE_NAME "RakarrackPlus Derelict"
const int C_DERE_PARAMETERS = 12;
enum Dere_Index
{
Dere_DryWet = 0,
Dere_Pan,
Dere_LR_Cross,
Dere_Drive,
Dere_Level,
Dere_Type,
Dere_Negate,
Dere_LPF,
Dere_HPF,
Dere_Color,
Dere_Prefilter,
Dere_Suboctave
};
static const char *dere_parameters[] =
{
strdup(NTS(Dere_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Dere_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Dere_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(Dere_Drive).c_str()), "Drive", "DRIVE",
strdup(NTS(Dere_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Dere_Type).c_str()), "Type", "TYPE",
strdup(NTS(Dere_Negate).c_str()), "Negate (Polarity Switch)", "NEG",
strdup(NTS(Dere_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(Dere_HPF).c_str()), "Highpass Filter", "HPF",
strdup(NTS(Dere_Color).c_str()), "Color", "COLOR",
strdup(NTS(Dere_Prefilter).c_str()), "Prefilter", "PREFILTER",
strdup(NTS(Dere_Suboctave).c_str()), "Suboctave", "OCT"
};
//Waveshaping(called by Distorsion effect and waveshape from OscilGen)
// void waveshapesmps (int n, float * smps, int type,
// int drive);
class Derelict : public Effect
{
public:
Derelict (int wave_res, int wave_upq, int wave_dnq, double sample_rate, uint32_t intermediate_bufsize);
~Derelict ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_DERE_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return DERELV2_URI; };
virtual std::string get_name(int) {return DERE_NAME; };
void initialize();
void clear_initialize();
void applyfilters (float * efxoutl, float * efxoutr, uint32_t period);
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
private:
uint32_t PERIOD;
double fSAMPLE_RATE;
int WAVE_RES, WAVE_UPQ, WAVE_DNQ;
public:
float inpll[4096];
float inplr[4096];
private:
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setlrcross (int _Plrcross);
void setoctave (int _Poctave);
void setlpf (int value);
void sethpf (int value);
//Parametrii
int Pvolume; //Volumul or E/R
int Ppanning; //Panning
int Plrcross; // L/R Mixing
int Pdrive; //the input amplification
int Plevel; //the ouput amplification
int Ptype; //Distorsion type
int Pnegate; //if the input is negated
int Plpf; //lowpass filter
int Phpf; //highpass filter
int Prfreq;
int Pprefiltering; //if you want to do the filtering before the distorsion
int Poctave; //mix sub octave
float rfreq;
float panning, lrcross, octave_memoryl, togglel, octave_memoryr, toggler, octmix;
float *octoutl, *octoutr;
//Parametrii reali
float* interpbuf;//buffer for filters
AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr, *blockDCl, *blockDCr, *DCl, *DCr;
class Waveshaper *wshapel, *wshaper;
class Filter *filterl, *filterr;
class FilterParams *filterpars;
};
#endif
| 4,663
|
C++
|
.h
| 124
| 33.540323
| 107
| 0.697669
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,513
|
Overdrive.h
|
Stazed_rakarrack-plus/src/FX/Overdrive.h
|
/*
ZynAddSubFX - a software synthesizer
Distorsion.h - Distorsion Effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu & Hernan Ordiales & Ryan Billing
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* File: Overdrive.h
* Author: sspresto
*
* Created on January 26, 2021, 8:16 AM
*/
#ifndef OVERDRIVE_H
#define OVERDRIVE_H
#include "Distorsion.h"
#define OVERDRIVELV2_URI "https://github.com/Stazed/rakarrack-plus#Overdrive"
#define OVERDRIVE_NAME "RakarrackPlus Overdrive"
const int C_OVERDRIVE_PARAMETERS = 13;
enum Overdrive_Index
{
Overdrive_DryWet = 0,
Overdrive_Pan,
Overdrive_LR_Cross,
Overdrive_Drive,
Overdrive_Level,
Overdrive_Type,
Overdrive_Negate,
Overdrive_LPF,
Overdrive_HPF,
Overdrive_Stereo,
Overdrive_Prefilter,
Overdrive_SKIP_11,
Overdrive_Suboctave
};
static const char *overdrive_parameters[] =
{
strdup(NTS(Overdrive_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Overdrive_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Overdrive_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(Overdrive_Drive).c_str()), "Drive", "DRIVE",
strdup(NTS(Overdrive_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Overdrive_Type).c_str()), "Type", "TYPE",
strdup(NTS(Overdrive_Negate).c_str()), "Negate (Polarity Switch)", "NEG",
strdup(NTS(Overdrive_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(Overdrive_HPF).c_str()), "Highpass Filter", "HPF",
strdup(NTS(Overdrive_Stereo).c_str()), "Stereo", "STEREO",
strdup(NTS(Overdrive_Prefilter).c_str()), "Prefilter", "PREFILTER"
};
class Overdrive: public Distorsion
{
public:
Overdrive(int wave_res, int wave_upq, int wave_dnq, double samplerate, uint32_t intermediate_bufsize);
void setpreset (int npreset);
int get_number_efx_parameters () {return C_OVERDRIVE_PARAMETERS;};
void set_random_parameters();
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return OVERDRIVELV2_URI; };
virtual std::string get_name(int) {return OVERDRIVE_NAME; };
};
#endif /* OVERDRIVE_H */
| 2,850
|
C++
|
.h
| 71
| 36.408451
| 106
| 0.720247
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,514
|
Synthfilter.h
|
Stazed_rakarrack-plus/src/FX/Synthfilter.h
|
/*
ZynAddSubFX - a software synthesizer
Synthfilter.h - Synthesizer filter effect
Copyright (C) 2010 Ryan Billing
Based on Analog Phaser derived from
Phaser.h/.C
Copyright (C) 2002-2005 Nasca Octavian Paul
Authors: Nasca Octavian Paul, Ryan Billing, Josep Andreu
Modified for rakarrack by Josep Andreu
Further modified for rakarrack by Ryan Billing (Transmogrifox) to model Analog Phaser behavior 2009
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SYNTHFILTER_H
#define SYNTHFILTER_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#define SYNTHLV2_URI "https://github.com/Stazed/rakarrack-plus#Synthfilter"
#define SYNTH_NAME "RakarrackPlus Synthfilter"
const int C_SYNTHFILTER_PARAMETERS = 16;
enum Synthfilter_Index
{
Synthfilter_DryWet = 0,
Synthfilter_Distort,
Synthfilter_LFO_Tempo,
Synthfilter_LFO_Random,
Synthfilter_LFO_Type,
Synthfilter_LFO_Stereo,
Synthfilter_Width,
Synthfilter_Feedback,
Synthfilter_LPF_Stages,
Synthfilter_HPF_Stages,
Synthfilter_Subtract,
Synthfilter_Depth,
Synthfilter_Env_Sens,
Synthfilter_Attack,
Synthfilter_Release,
Synthfilter_Offset
};
static const char *synth_parameters[] =
{
strdup(NTS(Synthfilter_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Synthfilter_Distort).c_str()), "Distort", "DIST",
strdup(NTS(Synthfilter_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Synthfilter_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(Synthfilter_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(Synthfilter_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(Synthfilter_Width).c_str()), "Width", "WIDTH",
strdup(NTS(Synthfilter_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Synthfilter_LPF_Stages).c_str()), "Lowpass Stages", "LSTAGES",
strdup(NTS(Synthfilter_HPF_Stages).c_str()), "Highpass Stages", "HSTAGES",
strdup(NTS(Synthfilter_Subtract).c_str()), "Subtract Output", "SUB",
strdup(NTS(Synthfilter_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(Synthfilter_Env_Sens).c_str()), "Envelope Sensitivity", "SENSE",
strdup(NTS(Synthfilter_Attack).c_str()), "Attack Time", "ATIME",
strdup(NTS(Synthfilter_Release).c_str()), "Release Time", "RTIME",
strdup(NTS(Synthfilter_Offset).c_str()), "HPF/LPF Offset", "OFFSET"
};
class Synthfilter : public Effect
{
public:
Synthfilter (double sample_rate, uint32_t intermediate_bufsize);
~Synthfilter ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_SYNTHFILTER_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return SYNTHLV2_URI; };
virtual std::string get_name(int) {return SYNTH_NAME; };
private:
//Control parameters
void setvolume (int _Pvolume);
void setdistortion (int _Pdistortion);
void setwidth (int _Pwidth);
void setfb (int _Pfb);
void setdepth (int _Pdepth);
uint32_t PERIOD;
//Phaser parameters
int Pvolume; //0//Used in Process.C to set wet/dry mix
int Pdistortion; //1//0...127//Model distortion
//2//Tempo//LFO frequency
//3//0...127//LFO Random
//4//0...max types//LFO Type
//5//0...127//LFO stereo offset
int Pwidth; //6//0...127//Phaser width (LFO amplitude)
int Pfb; //7//-64...64//feedback
int Plpstages; //8//0...12//Number of first-order Low-Pass stages
int Phpstages; //9//0...12//Number of first-order High-Pass stages
int Poutsub; //10//0 or 1//subtract the output instead of the adding it
int Pdepth; //11//0...127//Depth of phaser sweep
int Penvelope; //12//-64...64//envelope sensitivity
int Pattack; //13//0...1000ms//Attack Time
int Prelease; //14//0...500ms//Release Time
int Pbandwidth; //15//0...127//Separate high pass & low pass
//Internal Variables
float delta;
float distortion, fb, width, env, envdelta, sns, att, rls, fbl, fbr, depth, bandgain;
float *lyn1, *ryn1, *lx1hp, *ly1hp, *rx1hp, *ry1hp;
float oldlgain, oldrgain, inv_period;
float Rmin; // 2N5457 typical on resistance at Vgs = 0
float Rmax; // Resistor parallel to FET
float C, Clp, Chp; // Capacitor
EffectLFO* lfo; //Filter modulator
};
#endif
| 5,231
|
C++
|
.h
| 120
| 39.35
| 101
| 0.695558
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,515
|
Exciter.h
|
Stazed_rakarrack-plus/src/FX/Exciter.h
|
/*
Rakarrack Audio FX software
Exciter.h - Harmonic Enhancer
Based in Steve Harris LADSPA Plugin harmonic_gen
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EXCITER_H
#define EXCITER_H
#include "Effect.h"
#include "../EFX_common/HarmonicEnhancer.h"
#define EXCITERLV2_URI "https://github.com/Stazed/rakarrack-plus#Exciter"
#define EXCITER_NAME "RakarrackPlus Exciter"
const int C_EXCITER_PARAMETERS = 13;
enum Exciter_index
{
Exciter_Gain = 0,
Exciter_Harm_1,
Exciter_Harm_2,
Exciter_Harm_3,
Exciter_Harm_4,
Exciter_Harm_5,
Exciter_Harm_6,
Exciter_Harm_7,
Exciter_Harm_8,
Exciter_Harm_9,
Exciter_Harm_10,
Exciter_LPF,
Exciter_HPF
};
static const char *exciter_parameters[] =
{
strdup(NTS(Exciter_Gain).c_str()), "Gain", "GAIN",
strdup(NTS(Exciter_Harm_1).c_str()), "1st Harmonic", "HAR1",
strdup(NTS(Exciter_Harm_2).c_str()), "2nd Harmonic", "HAR2",
strdup(NTS(Exciter_Harm_3).c_str()), "3rd Harmonic", "HAR3",
strdup(NTS(Exciter_Harm_4).c_str()), "4th Harmonic", "HAR4",
strdup(NTS(Exciter_Harm_5).c_str()), "5th Harmonic", "HAR5",
strdup(NTS(Exciter_Harm_6).c_str()), "6th Harmonic", "HAR6",
strdup(NTS(Exciter_Harm_7).c_str()), "7th Harmonic", "HAR7",
strdup(NTS(Exciter_Harm_8).c_str()), "8th Harmonic", "HAR8",
strdup(NTS(Exciter_Harm_9).c_str()), "9th Harmonic", "HAR9",
strdup(NTS(Exciter_Harm_10).c_str()), "10th Harmonic", "HAR10",
strdup(NTS(Exciter_LPF).c_str()), "Low-Pass Filter Cutoff", "LPF",
strdup(NTS(Exciter_HPF).c_str()), "High-Pass Filter Cutoff", "HPF"
};
class Exciter : public Effect
{
public:
Exciter (double sample_rate, uint32_t intermediate_bufsize);
~Exciter ();
void out (float * efxoutl, float * efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_EXCITER_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return EXCITERLV2_URI; };
virtual std::string get_name(int) {return EXCITER_NAME; };
private:
void setvolume (int value);
void setlpf (int value);
void sethpf (int value);
void sethar(int num, int value);
uint32_t PERIOD;
int Prm[10];
int Pvolume;
int lpffreq;
int hpffreq;
float rm[10];
class HarmEnhancer *harm;
};
#endif
| 3,366
|
C++
|
.h
| 89
| 33.752809
| 79
| 0.694504
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,516
|
StereoHarm.h
|
Stazed_rakarrack-plus/src/FX/StereoHarm.h
|
/*
rakarrack - a guitar effects software
StereoHarm.h - Stereo Harmonizer definitions
Copyright (C) 2008 Josep Andreu
Author: Josep Andreu
Using Stephan M. Bernsee smbPitchShifter engine.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef STEREOHARM_H
#define STEREOHARM_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/smbPitchShift.h"
#include "../EFX_common/Resample.h"
#define STEROHARMLV2_URI "https://github.com/Stazed/rakarrack-plus#StereoHarm"
#define SHARMNOMIDLV2_URI "https://github.com/Stazed/rakarrack-plus#StereoHarm_no_mid"
#define SHARM_NAME "RakarrackPlus StereoHarmonizer"
#define SHARM_NAME_NO_MIDI "RakarrackPlus StereoHarmonizer (no midi)"
const int C_SHARM_PARAMETERS = 12;
enum Sharm_Index
{
Sharm_DryWet = 0,
Sharm_L_Gain,
Sharm_L_Interval,
Sharm_L_Chroma,
Sharm_R_Gain,
Sharm_R_Interval,
Sharm_R_Chroma,
Sharm_Select,
Sharm_Note,
Sharm_Chord,
Sharm_MIDI,
Sharm_LR_Cross
};
static const char *sharm_parameters[] =
{
strdup(NTS(Sharm_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Sharm_L_Gain).c_str()), "Left Gain", "GAINL",
strdup(NTS(Sharm_L_Interval).c_str()), "Left Interval", "INTL",
strdup(NTS(Sharm_L_Chroma).c_str()), "Left Chroma", "CHRML",
strdup(NTS(Sharm_R_Gain).c_str()), "Right Gain", "GAINR",
strdup(NTS(Sharm_R_Interval).c_str()), "Right Interval", "INTR",
strdup(NTS(Sharm_R_Chroma).c_str()), "Right Chroma", "CHR",
strdup(NTS(Sharm_Select).c_str()), "Select Chord Mode", "SELECT",
strdup(NTS(Sharm_Note).c_str()), "Note", "NOTE",
strdup(NTS(Sharm_Chord).c_str()), "Chord", "CHORD",
strdup(NTS(Sharm_MIDI).c_str()) , "MIDI Mode", "MIDI",
strdup(NTS(Sharm_LR_Cross).c_str()), "Left/Right Crossover", "LRC"
};
class StereoHarm : public Effect
{
public:
StereoHarm (long int Quality, int DS, int uq, int dq, double sample_rate, uint32_t intermediate_bufsize);
~StereoHarm ();
void out (float *efxoutl, float *efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_SHARM_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int type);
virtual std::string get_name(int type);
void initialize();
void clear_initialize();
void adjust(int DS, uint32_t period);
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
private:
int STE_DOWN;
uint32_t PERIOD;
unsigned int SAMPLE_RATE;
public:
int Pintervall;
int Pintervalr;
int PMIDI;
int PSELECT;
int mira;
int DS_state;
long window;
long int hq;
double u_up;
double u_down;
float *outil,*outir;
float *outol,*outor;
float *templ, *tempr;
float r_ratiol;
float r_ratior;
private:
unsigned int nPERIOD;
float nRATIO;
int nSAMPLE_RATE;
float nfSAMPLE_RATE;
int Pvolume;
int Plrcross;
int Pgainl;
int Pgainr;
int Pchromel;
int Pchromer;
int Pnote;
int Ptype;
float gainl,gainr;
float intervall;
float intervalr;
float chromel;
float chromer;
float lrcross;
void setvolume (int Pvolume);
void setinterval (int chan, int value);
void setchrome(int chan, int value);
void setgain (int chan, int value);
void setMIDI (int PMIDI);
void setlrcross(int value);
class Resample *U_Resample;
class Resample *D_Resample;
PitchShifter *PSl, *PSr;
};
#endif
| 4,399
|
C++
|
.h
| 133
| 28.819549
| 109
| 0.698529
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,517
|
Reverbtron.h
|
Stazed_rakarrack-plus/src/FX/Reverbtron.h
|
/*
Reverbtron.h - Reverbtron Effect
Author: Ryan Billing & Josep Andreu
Adapted effect structure of ZynAddSubFX - a software synthesizer
Author: Nasca Octavian Paul
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef REVERBTRON_H
#define REVERBTRON_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/Resample.h"
#define REVTRONLV2_URI "https://github.com/Stazed/rakarrack-plus#Reverbtron"
#define REVTRON_NAME "RakarrackPlus Reverbtron"
const int C_REVTRON_PARAMETERS = 16;
enum Revtron_Index
{
Revtron_DryWet = 0,
Revtron_Fade,
Revtron_Safe,
Revtron_Length,
Revtron_User_File,
Revtron_I_Delay,
Revtron_Damp,
Revtron_Level,
Revtron_Set_File,
Revtron_Stretch,
Revtron_Feedback,
Revtron_Pan,
Revtron_Ex_Stereo,
Revtron_Shuffle,
Revtron_LPF,
Revtron_Diffusion
};
static const char *revtron_parameters[] =
{
strdup(NTS(Revtron_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Revtron_Fade).c_str()), "Fade", "FADE",
strdup(NTS(Revtron_Safe).c_str()), "Safe", "SAFE",
strdup(NTS(Revtron_Length).c_str()), "Length", "LENGTH",
strdup(NTS(Revtron_I_Delay).c_str()), "Initial Delay", "DELAY",
strdup(NTS(Revtron_Damp).c_str()), "Dampening", "DAMP",
strdup(NTS(Revtron_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Revtron_Stretch).c_str()), "Time Stretch", "STRETCH",
strdup(NTS(Revtron_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Revtron_Pan).c_str()), "Pan", "PAN",
strdup(NTS(Revtron_Ex_Stereo).c_str()), "Extra Stereo", "ES",
strdup(NTS(Revtron_Shuffle).c_str()), "Shuffle", "SH",
strdup(NTS(Revtron_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(Revtron_Diffusion).c_str()), "Diffusion", "DIFFUSE"
};
class RvbFile
{
public:
char Filename[128];
float tdata[2000];
float ftime[2000];
int data_length;
float maxtime;
float maxdata;
RvbFile ():
Filename(),
tdata(),
ftime(),
data_length(),
maxtime(),
maxdata() {}
};
class Reverbtron : public Effect
{
public:
Reverbtron (int DS, int uq, int dq, double sample_rate, uint32_t intermediate_bufsize);
~Reverbtron ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_REVTRON_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return REVTRONLV2_URI; };
virtual std::string get_name(int) {return REVTRON_NAME; };
void initialize();
void clear_initialize();
int setfile (int value);
void adjust(int DS, double sample_rate);
RvbFile loadfile(char* filename);
void applyfile(const RvbFile &file);
void set_user_files(const std::vector<User_Files> &rvb_files){RVB_Files = rvb_files;};
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
char Filename[128];
RvbFile File;
private:
void setvolume (int _Pvolume);
void setpanning (int value);
void sethidamp (int _Phidamp);
void setlpf (int value);
void setfb(int value);
void convert_time();
RvbFile loaddefault();
std::vector<User_Files> RVB_Files;
uint32_t PERIOD;
int nPERIOD;
int nSAMPLE_RATE;
double fSAMPLE_RATE;
float nfSAMPLE_RATE;
//Parametrii
int Pvolume; //This is master wet/dry mix like other FX...but I am finding it is not useful
int Ppanning; //Panning
int Plrcross; // L/R Mixing // This is a mono effect, so lrcross and panning are pointless
int Phidamp;
int Plevel; //This should only adjust the level of the IR effect, and not wet/dry mix
int Plength; //20... 1500// Set maximum number of IR points to calculate.
int Puser; //-64...64//Feedback.
int Pstretch; //-64 ... 64//For stretching reverb responses
int Pidelay; //0 ... 500ms// initial delay time
int Filenum;
int Psafe;
int Pfb; //-64 ... 64// amount of feedback
int Pfade;
int Pes; //0 or 1// Add stereo spatialization
int Prv; //Shuffle
int Plpf;
int Pdiff;
int imctr;
int imax;
int offset;
int hoffset;
int maxx_size;
//int data_length;
int error;// flag if error when loading file
int Llength; //Plength but limited
// int avgtime;
int hrtf_size;
int hlength;
int DS_state;
float nRATIO;
int *time, *rndtime;
double u_up;
double u_down;
//float fstretch, idelay, ffade, maxtime, maxdata, decay, diffusion;
float fstretch, idelay, ffade, decay, diffusion;
float lpanning, rpanning, hidamp, alpha_hidamp, convlength, oldl;
//float *data, *lxn, *imdelay, *ftime, *tdata, *rnddata, *hrtf;
float *data, *lxn, *imdelay, *rnddata, *hrtf;
float *templ, *tempr;
float level,fb, feedback,levpanl,levpanr;
float roomsize;
class Resample *U_Resample;
class Resample *D_Resample;
float* interpbuf; //buffer for filters
class AnalogFilter *lpfl, *lpfr; //filters
};
#endif
| 5,969
|
C++
|
.h
| 170
| 30.717647
| 95
| 0.683296
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,518
|
Compressor.h
|
Stazed_rakarrack-plus/src/FX/Compressor.h
|
/*
rakarrack - a guitar effects software
Compressor.h - Compressor Effect definitions
Based on artscompressor.cc by Matthias Kretz <kretz@kde.org>
Stefan Westerfeld <stefan@space.twc.de>
Copyright (C) 2008-2010 Josep Andreu
Author: Josep Andreu & Ryan Billing
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef COMPRESSOR_H
#define COMPRESSOR_H
#include "Effect.h"
#define COMPLV2_URI "https://github.com/Stazed/rakarrack-plus#comp"
#define COMP_NAME "RakarrackPlus Compressor"
const int C_COMPRESS_PARAMETERS = 9;
enum Compress_Index
{
Compress_Threshold = 0,
Compress_Ratio,
Compress_Output,
Compress_Attack,
Compress_Release,
Compress_Auto_Out,
Compress_Knee,
Compress_Stereo,
Compress_Peak
};
static const char *comp_parameters[] =
{
strdup(NTS(Compress_Threshold).c_str()), "Threshold", "THRESHOLD",
strdup(NTS(Compress_Ratio).c_str()), "Ratio", "RATIO",
strdup(NTS(Compress_Output).c_str()), "Output Gain", "OUTPUT",
strdup(NTS(Compress_Attack).c_str()), "Attack Time", "ATTACK",
strdup(NTS(Compress_Release).c_str()), "Release Time", "RELEASE",
strdup(NTS(Compress_Auto_Out).c_str()), "Auto Output", "AUTOOUT",
strdup(NTS(Compress_Knee).c_str()), "Knee", "KNEE",
strdup(NTS(Compress_Stereo).c_str()), "Stereo", "STEREO",
strdup(NTS(Compress_Peak).c_str()), "Peak", "PEAK"
};
class Compressor : public Effect
{
public:
Compressor (double sample_rate, uint32_t intermediate_bufsize);
virtual ~Compressor ();
void out (float *efxoutl, float *efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
virtual void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_COMPRESS_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return COMPLV2_URI; };
virtual std::string get_name(int) {return COMP_NAME; };
// Compressor
int tatt; // attack time (ms)
int trel; // release time (ms)
int tratio;
int toutput;
int tthreshold;
int a_out;
int stereo;
int tknee;
int peak;
int clipping;
int limit;
private:
float cSAMPLE_RATE;
uint32_t PERIOD;
float rvolume;
float lvolume;
float rvolume_db;
float lvolume_db;
float thres_db; // threshold
float knee;
float thres_mx;
float kpct;
float ratio; // ratio
float kratio; // ratio maximum for knee region
float eratio; // dynamic ratio
float makeup; // make-up gain
float makeuplin;
float outlevel;
float att, attr, attl;
float rel, relr, rell;
float relcnst, attconst;
int ltimer, rtimer, hold;
float rgain;
float rgain_old;
float lgain;
float lgain_old;
float lgain_t;
float rgain_t;
float coeff_kratio;
float coeff_ratio;
float coeff_knee;
float coeff_kk;
float lpeak;
float rpeak;
};
#endif
| 3,852
|
C++
|
.h
| 116
| 28.896552
| 72
| 0.699431
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,519
|
Echo.h
|
Stazed_rakarrack-plus/src/FX/Echo.h
|
/*
ZynAddSubFX - a software synthesizer
Echo.h - Echo Effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
Reverse Echo by Transmogrifox
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ECHO_H
#define ECHO_H
#include "Effect.h"
#include "../EFX_common/delayline.h"
#define ECHOLV2_URI "https://github.com/Stazed/rakarrack-plus#eco"
#define ECHO_NAME "RakarrackPlus Echo"
const int C_ECHO_PARAMETERS = 9;
enum Echo_Index
{
Echo_DryWet = 0,
Echo_Pan,
Echo_Delay,
Echo_LR_Delay,
Echo_LR_Cross,
Echo_Feedback,
Echo_Damp,
Echo_Reverse,
Echo_Direct
};
static const char *echo_parameters[] =
{
strdup(NTS(Echo_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Echo_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Echo_Delay).c_str()), "Delay", "DELAY",
strdup(NTS(Echo_LR_Delay).c_str()), "Left/Right Delay Offset", "LR_DELAY",
strdup(NTS(Echo_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(Echo_Feedback).c_str()), "Feedback", "FEEDBACK",
strdup(NTS(Echo_Damp).c_str()), "Damping", "DAMP",
strdup(NTS(Echo_Reverse).c_str()), "Reverse", "REV",
strdup(NTS(Echo_Direct).c_str()), "Direct", "DIRECT"
};
class Echo : public Effect
{
public:
Echo (double sample_rate, uint32_t intermediate_bufsize);
~Echo ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_ECHO_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return ECHOLV2_URI; };
virtual std::string get_name(int) {return ECHO_NAME; };
void Tempo2Delay(int delay);
private:
uint32_t PERIOD;
//Parametrii
int Pvolume; //Volumul or E/R
int Ppanning; //Panning
int Pdelay;
int Plrdelay; // L/R delay difference
int Plrcross; // L/R Mixing
int Pfb; //Feed-back-ul
int Phidamp;
int Preverse;
int Pdirect;
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setdelay (int _Pdelay);
void setlrdelay (int _Plrdelay);
void setlrcross (int _Plrcross);
void setfb (int _Pfb);
void sethidamp (int _Phidamp);
void setreverse (int _Preverse);
void setdirect (int _Pdirect);
//Parametrii reali
void initdelays ();
int dl, dr;
float delay, lrdelay;
int kl, kr, rvkl, rvkr, rvfl, rvfr, maxx_delay, fade;
class delayline *ldelay, *rdelay;
float ltime, rtime;
float oldl, oldr; //pt. lpf
float panning, lrcross, fb, hidamp, reverse, ireverse;
float Srate_Attack_Coeff;
};
#endif
| 3,542
|
C++
|
.h
| 101
| 30.881188
| 80
| 0.692488
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,520
|
Cabinet.h
|
Stazed_rakarrack-plus/src/FX/Cabinet.h
|
/*
Rakarrack
Cabinet.C - eq curves to approximate a guitar cabinet
Copyright (C) 2015 Spencer Jackson
Author: Spencer Jackson
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef CABINET_H
#define CABINET_H
#include "EQ.h"
#define CABLV2_URI "https://github.com/Stazed/rakarrack-plus#cabe"
#define CAB_NAME "RakarrackPlus Cabinet"
/* Used for Gain and Preset setting */
const int C_CABINET_PARAMETERS = 2;
enum Cabinet_Index
{
Cabinet_Preset_Idx = 0,
Cabinet_Gain
};
static const char *cab_parameters[] =
{
strdup(NTS(Cabinet_Preset_Idx).c_str()), "Preset", "PRESET",
strdup(NTS(Cabinet_Gain).c_str()), "Gain", "GAIN"
};
class Cabinet :public EQ
{
public:
Cabinet (double sample_frequency, uint32_t intermediate_bufsize);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpreset(int npreset);
void changepar (int npar, int value);
int getpar (int npar);
int get_number_efx_parameters () {return C_CABINET_PARAMETERS;};
void set_random_parameters();
void initialize();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return CABLV2_URI; };
virtual std::string get_name(int) {return CAB_NAME; };
};
#endif
| 2,010
|
C++
|
.h
| 53
| 34.54717
| 79
| 0.737578
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,521
|
Ring.h
|
Stazed_rakarrack-plus/src/FX/Ring.h
|
/*
ZynAddSubFX - a software synthesizer
Copyright (C) 2002-2005 Nasca Octavian Paul
Based on Ring Modulator Steve Harris LADSPA plugin.
Ring.h - Distorsion Effect
Modified and adapted to rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef RING_H
#define RING_H
#include "Effect.h"
#define RINGLV2_URI "https://github.com/Stazed/rakarrack-plus#Ring"
#define RING_NAME "RakarrackPlus Ring"
const int C_RING_PARAMETERS = 13;
enum Ring_Index
{
Ring_DryWet = 0,
Ring_Pan,
Ring_LR_Cross,
Ring_Level,
Ring_Depth,
Ring_Freq,
Ring_Stereo,
Ring_Sine,
Ring_Triangle,
Ring_Saw,
Ring_Square,
Ring_Input,
Ring_Auto_Freq
};
static const char *ring_parameters[] =
{
strdup(NTS(Ring_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Ring_Pan).c_str()), "Pan", "PAN",
strdup(NTS(Ring_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(Ring_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Ring_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(Ring_Freq).c_str()), "Frequency", "FREQ",
strdup(NTS(Ring_Stereo).c_str()), "Stereo", "STEREO",
strdup(NTS(Ring_Sine).c_str()), "Sine", "SIN",
strdup(NTS(Ring_Triangle).c_str()), "Triangle", "TRI",
strdup(NTS(Ring_Saw).c_str()), "Sawtooth", "SAW",
strdup(NTS(Ring_Square).c_str()), "Square", "SQUARE",
strdup(NTS(Ring_Input).c_str()), "Input Gain", "INPUT",
strdup(NTS(Ring_Auto_Freq).c_str()), "Auto-Frequency", "AFREQ"
};
class Ring : public Effect
{
public:
Ring (double sample_rate, uint32_t intermediate_bufsize);
~Ring ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void setscale();
void cleanup ();
int get_number_efx_parameters () {return C_RING_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return RINGLV2_URI; };
virtual std::string get_name(int) {return RING_NAME; };
void Create_Tables(float sample_rate);
int Pafreq;
int Pfreq;
private:
void setvolume (int Pvolume);
void setpanning (int Ppanning);
void setlrcross (int Plrcross);
unsigned int SAMPLE_RATE;
uint32_t PERIOD;
//Parametrii
int Pvolume; //Volumul or E/R
int Ppanning; //Panning
int Plrcross; // L/R Mixing
int Pinput;
int Plevel; //the ouput amplification
int Pdepthp;
int Psin; //highpass filter
int Ptri;
int Psaw;
int Psqu;
int Pstereo; //0=mono,1=stereo
//Parametrii reali
unsigned int offset;
float panning, lrcross;
float *sin_tbl, *tri_tbl, *saw_tbl, *squ_tbl;
float sin,tri,saw,squ,scale,depth, idepth;
};
#endif
| 3,556
|
C++
|
.h
| 102
| 30.617647
| 79
| 0.685347
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,522
|
Harmonizer.h
|
Stazed_rakarrack-plus/src/FX/Harmonizer.h
|
/*
rakarrack - a guitar effects software
Harmonizer.h - Harmonizer definitions
Copyright (C) 2008 Josep Andreu
Author: Josep Andreu
Using Stephan M. Bernsee smbPitchShifter engine.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef HARMONIZER_H
#define HARMONIZER_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/smbPitchShift.h"
#include "../EFX_common/Resample.h"
#define HARMLV2_URI "https://github.com/Stazed/rakarrack-plus#har"
#define HARMNOMIDLV2_URI "https://github.com/Stazed/rakarrack-plus#har_no_mid"
#define HARM_NAME_NO_MIDI "RakarrackPlus Harmonizer (no midi)"
#define HARM_NAME "RakarrackPlus Harmonizer"
const int C_HARM_PARAMETERS = 11;
enum Harm_Index
{
Harm_DryWet = 0,
Harm_Pan,
Harm_Gain,
Harm_Interval,
Harm_Filter_Freq,
Harm_Select,
Harm_Note,
Harm_Chord,
Harm_Filter_Gain,
Harm_Filter_Q,
Harm_MIDI
};
static const char *harm_parameters[] =
{
strdup(NTS(Harm_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Harm_Pan).c_str()), "Pan", "PAN",
strdup(NTS(Harm_Gain).c_str()), "Gain", "GAIN",
strdup(NTS(Harm_Interval).c_str()), "Interval", "INT",
strdup(NTS(Harm_Filter_Freq).c_str()), "Filter Frequency", "FREQ",
strdup(NTS(Harm_Select).c_str()), "Select Chord Mode", "SELECT",
strdup(NTS(Harm_Note).c_str()), "Note", "NOTE",
strdup(NTS(Harm_Chord).c_str()), "Chord", "CHORD",
strdup(NTS(Harm_Filter_Gain).c_str()), "Filter Gain", "FGAIN",
strdup(NTS(Harm_Filter_Q).c_str()), "Filter Q", "FQ",
strdup(NTS(Harm_MIDI).c_str()), "MIDI Mode", "MIDI"
};
class Harmonizer :public Effect
{
public:
Harmonizer (long int Quality, int DS, int uq, int dq, double sample_rate, uint32_t intermediate_bufsize);
~Harmonizer ();
void out (float *efxoutl, float *efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_HARM_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int);
virtual std::string get_name(int);
void initialize();
void clear_initialize();
void applyfilters (float * efxoutl, uint32_t period);
void adjust(int DS, uint32_t period);
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
int Pinterval;
int PMIDI;
int PSELECT;
float r_ratio;
int mira;
int DS_state;
int nPERIOD;
int nSAMPLE_RATE;
long window;
long int hq;
double u_up;
double u_down;
float nfSAMPLE_RATE;
float *outi;
float *outo;
float *templ, *tempr;
private:
int Pvolume;
int Pgain;
int Ppan;
int Pnote;
int Ptype;
int fPfreq;
int fPgain;
int fPq;
float panning;
float gain;
float interval;
void setvolume (int Pvolume);
void setpanning (int Ppan);
void setinterval (int Pinterval);
void setgain (int Pgain);
void setMIDI (int PMIDI);
void fsetfreq (int value);
void fsetgain (int value);
void fsetq (int value);
AnalogFilter *pl;
float* interpbuf; //buffer for filters
class Resample *U_Resample;
class Resample *D_Resample;
PitchShifter *PS;
unsigned int SAMPLE_RATE;
double fSAMPLE_RATE;
uint32_t PERIOD;
bool DS_init;
};
#endif
| 4,231
|
C++
|
.h
| 130
| 28.276923
| 109
| 0.693238
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,523
|
Valve.h
|
Stazed_rakarrack-plus/src/FX/Valve.h
|
/*
ZynAddSubFX - a software synthesizer
Copyright (C) 2002-2005 Nasca Octavian Paul
Based on valve Steve Harris LADSPA plugin.
Valve.h - Distorsion Effect
Modified and adapted to rakarrack by Josep Andreu.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef VALVE_H
#define VALVE_H
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/HarmonicEnhancer.h"
#define VALVELV2_URI "https://github.com/Stazed/rakarrack-plus#Valve"
#define VALVE_NAME "RakarrackPlus Valve"
const int C_VALVE_PARAMETERS = 13;
enum Valve_Index
{
Valve_DryWet = 0,
Valve_Pan,
Valve_LR_Cross,
Valve_Drive,
Valve_Level,
Valve_Negate,
Valve_LPF,
Valve_HPF,
Valve_Stereo,
Valve_Prefilter,
Valve_Distortion,
Valve_Ex_Dist,
Valve_Presence
};
static const char *valve_parameters[] =
{
strdup(NTS(Valve_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Valve_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Valve_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(Valve_Drive).c_str()), "Drive", "DRIVE",
strdup(NTS(Valve_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Valve_Negate).c_str()), "Negate (Polarity Switch)", "NEG",
strdup(NTS(Valve_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(Valve_HPF).c_str()), "Highpass Filter", "HPF",
strdup(NTS(Valve_Stereo).c_str()), "Stereo", "STEREO",
strdup(NTS(Valve_Prefilter).c_str()), "Prefilter", "PREFILTER",
strdup(NTS(Valve_Distortion).c_str()), "Distortion", "DIST",
strdup(NTS(Valve_Ex_Dist).c_str()), "Extra Distortion", "ED",
strdup(NTS(Valve_Presence).c_str()), "Presence", "PRES"
};
class Valve : public Effect
{
public:
Valve (double sample_rate, uint32_t intermediate_bufsize);
~Valve ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
float Wshape(float x);
void cleanup ();
int get_number_efx_parameters () {return C_VALVE_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return VALVELV2_URI; };
virtual std::string get_name(int) {return VALVE_NAME; };
void initialize();
void clear_initialize();
void applyfilters (float * efxoutl, float * efxoutr);
private:
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setlrcross (int _Plrcross);
void setlpf (int value);
void sethpf (int value);
void setpresence(int value);
void init_coefs();
uint32_t PERIOD;
double fSAMPLE_RATE;
//Parametrii
int Pvolume; //Volumul or E/R
int Ppanning; //Panning
int Plrcross; // L/R Mixing
int Pdrive; //the input amplification
int Plevel; //the ouput amplification
int Pnegate; //if the input is negated
int Plpf; //lowpass filter
int Phpf; //highpass filter
int Pstereo; //0=mono,1=stereo
int Pprefiltering; //if you want to do the filtering before the distorsion
int Q_q;
int Ped;
int Presence;
//Parametrii reali
float panning, lrcross, q, dist, otml,otmr, itml, itmr, factor, atk;
float rm[10];
float coef;
float qcoef;
float fdist;
float inputvol;
float* interpbuf; //buffer for filters
AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr;
class HarmEnhancer *harm;
};
#endif
| 4,180
|
C++
|
.h
| 115
| 32.06087
| 79
| 0.692365
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,524
|
ParametricEQ.h
|
Stazed_rakarrack-plus/src/FX/ParametricEQ.h
|
/*
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* File: ParametricEQ.h
* Author: sspresto
*
* Created on January 11, 2021, 7:27 PM
*/
#ifndef PARAMETRICEQ_H
#define PARAMETRICEQ_H
#include "EQ.h"
#define EQPLV2_URI "https://github.com/Stazed/rakarrack-plus#eqp"
#define EQP_NAME "RakarrackPlus Parametric EQ"
const int C_PARAMETRIC_EQ_PARAMETERS = 10;
enum ParametricEQ_Index
{
Parametric_Low_Freq = 0,
Parametric_Low_Gain,
Parametric_Low_Q,
Parametric_Mid_Freq,
Parametric_Mid_Gain,
Parametric_Mid_Q,
Parametric_High_Freq,
Parametric_High_Gain,
Parametric_High_Q,
Parametric_Gain // 9
};
static const char *eqp_parameters[] =
{
strdup(NTS(Parametric_Gain).c_str()), "Gain", "GAIN",
strdup(NTS(Parametric_Low_Freq).c_str()), "Low Frequency", "LFREQ",
strdup(NTS(Parametric_Low_Gain).c_str()), "Low Gain", "LGAIN",
strdup(NTS(Parametric_Low_Q).c_str()), "Low Width", "LQ",
strdup(NTS(Parametric_Mid_Freq).c_str()), "Mid Frequency", "MFREQ",
strdup(NTS(Parametric_Mid_Gain).c_str()), "Mid Gain", "MGAIN",
strdup(NTS(Parametric_Mid_Q).c_str()), "Mid Width", "MQ",
strdup(NTS(Parametric_High_Freq).c_str()), "High Frequency", "HFREQ",
strdup(NTS(Parametric_High_Gain).c_str()), "High Gain", "HGAIN",
strdup(NTS(Parametric_High_Q).c_str()), "High Width", "HQ"
};
class ParametricEQ :public EQ
{
public:
ParametricEQ (double sample_frequency, uint32_t intermediate_bufsize);
void setpreset(int npreset);
void changepar (int npar, int value);
int getpar (int npar);
int get_number_efx_parameters () {return C_PARAMETRIC_EQ_PARAMETERS;};
void set_random_parameters();
void initialize();
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return EQPLV2_URI; };
virtual std::string get_name(int) {return EQP_NAME; };
private:
};
#endif /* PARAMETRICEQ_H */
| 2,586
|
C++
|
.h
| 66
| 35.5
| 79
| 0.7056
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,525
|
CompBand.h
|
Stazed_rakarrack-plus/src/FX/CompBand.h
|
/*
CompBand.h - 4 Bands Compressor
Using Compressor and AnalogFilters by other authors.
Based on artscompressor.cc by Matthias Kretz <kretz@kde.org>
Stefan Westerfeld <stefan@space.twc.de>
Modified by Ryan Billing & Josep Andreu
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
ZynAddSubFX - a software synthesizer
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef COMPBANDL_H
#define COMPBANDL_H
#include "Effect.h"
#include "../Limiter.h"
#include "../EFX_common/AnalogFilter.h"
#define MBCOMPLV2_URI "https://github.com/Stazed/rakarrack-plus#CompBand"
#define MBCOMP_NAME "RakarrackPlus CompBand"
const int C_COMPBAND_PARAMETERS = 13;
enum CompBand_Index
{
CompBand_DryWet = 0,
CompBand_Low_Ratio,
CompBand_Mid_1_Ratio,
CompBand_Mid_2_Ratio,
CompBand_High_Ratio,
CompBand_Low_Thresh,
CompBand_Mid_1_Thresh,
CompBand_Mid_2_Thresh,
CompBand_High_Thresh,
CompBand_Cross_1,
CompBand_Cross_2,
CompBand_Cross_3,
CompBand_Gain
};
static const char *compband_parameters[] =
{
strdup(NTS(CompBand_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(CompBand_Low_Ratio).c_str()), "Low Band Ratio", "LR",
strdup(NTS(CompBand_Mid_1_Ratio).c_str()), "Mid Band 1 Ratio", "M1R",
strdup(NTS(CompBand_Mid_2_Ratio).c_str()), "Mid Band 2 Ratio", "M2R",
strdup(NTS(CompBand_High_Ratio).c_str()), "High Band Ratio", "HR",
strdup(NTS(CompBand_Low_Thresh).c_str()), "Low Band Threshold", "LT",
strdup(NTS(CompBand_Mid_1_Thresh).c_str()), "Mid Band 1 Threshold", "M1T",
strdup(NTS(CompBand_Mid_2_Thresh).c_str()), "Mid Band 2 Threshold", "M2T",
strdup(NTS(CompBand_High_Thresh).c_str()), "High Threshold", "HT",
strdup(NTS(CompBand_Cross_1).c_str()), "Low/Mid1 Crossover", "LMCR",
strdup(NTS(CompBand_Cross_2).c_str()), "Mid1/Mid2 Crossover", "MMCR",
strdup(NTS(CompBand_Cross_3).c_str()), "Mid2/High Crossover", "MHCR",
strdup(NTS(CompBand_Gain).c_str()), "Gain", "GAIN"
};
class CompBand : public Effect
{
public:
CompBand (double sample_rate, uint32_t intermediate_bufsize);
~CompBand ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_COMPBAND_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return MBCOMPLV2_URI; };
virtual std::string get_name(int) {return MBCOMP_NAME; };
void initialize();
void clear_initialize();
float level;
float *lowl;
float *lowr;
float *midll;
float *midlr;
float *midhl;
float *midhr;
float *highl;
float *highr;
private:
void setvolume (int Pvolume);
void setlevel(int value);
void setratio (int ch, int value);
void setthres (int ch, int value);
void setCross1 (int value);
void setCross2 (int value);
void setCross3 (int value);
uint32_t PERIOD;
double fSAMPLE_RATE;
//Parametrii
int Pvolume; //Volumul or E/R
int Plevel;
int PLratio;
int PMLratio;
int PMHratio;
int PHratio;
int PLthres;
int PMLthres;
int PMHthres;
int PHthres;
int Cross1;
int Cross2;
int Cross3;
//Parametrii reali
AnalogFilter *lpf1l, *lpf1r, *hpf1l, *hpf1r;
AnalogFilter *lpf2l, *lpf2r, *hpf2l, *hpf2r;
AnalogFilter *lpf3l, *lpf3r, *hpf3l, *hpf3r;
float * interpbuf;//buffer for filters
Compressor *CL,*CML,*CMH,*CH;
};
#endif
| 4,364
|
C++
|
.h
| 121
| 31.727273
| 80
| 0.696955
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,526
|
ShelfBoost.h
|
Stazed_rakarrack-plus/src/FX/ShelfBoost.h
|
/*
Rakarrack Audio FX software
ShelfBoost.h - Tone Booster
Modified for rakarrack by Ryan Billing & Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SHELFBOOST_H
#define SHELFBOOST_H
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#define SHELFLV2_URI "https://github.com/Stazed/rakarrack-plus#ShelfBoost"
#define SHELF_NAME "RakarrackPlus Shelf Boost"
const int C_SHELF_PARAMETERS = 5;
enum Shelf_Index
{
Shelf_Gain = 0,
Shelf_Presence,
Shelf_Tone,
Shelf_Stereo,
Shelf_Level
};
static const char *shelf_parameters[] =
{
strdup(NTS(Shelf_Gain).c_str()), "Gain", "GAIN",
strdup(NTS(Shelf_Presence).c_str()), "Presence", "PRES",
strdup(NTS(Shelf_Tone).c_str()), "Tone", "TONE",
strdup(NTS(Shelf_Stereo).c_str()), "Stereo", "STEREO",
strdup(NTS(Shelf_Level).c_str()), "Level", "LEVEL"
};
class ShelfBoost : public Effect
{
public:
ShelfBoost (double sample_rate, uint32_t intermediate_bufsize);
~ShelfBoost ();
void out (float * efxoutl, float * efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_SHELF_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return SHELFLV2_URI; };
virtual std::string get_name(int) {return SHELF_NAME; };
void initialize();
void clear_initialize();
void set_q(int value);
void set_freq(int value);
void set_level(int value);
private:
void setvolume (int value);
uint32_t PERIOD;
double fSAMPLE_RATE;
int Pvolume;
int Plevel;
int Pq1;
int Pfreq1;
int Pstereo;
float freq1,q1,gain,u_gain;
class AnalogFilter *RB1l, *RB1r;
float* interpbuf; //buffer for filters
};
#endif
| 2,732
|
C++
|
.h
| 77
| 31.519481
| 79
| 0.711348
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,527
|
StompBox.h
|
Stazed_rakarrack-plus/src/FX/StompBox.h
|
/*
Rakarrack Audio FX software
Stompbox.h - stompbox modeler
Using Steve Harris LADSPA Plugin harmonic_gen
Modified for rakarrack by Ryan Billing & Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef STOMPBOX_H
#define STOMPBOX_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/Waveshaper.h"
#define STOMPLV2_URI "https://github.com/Stazed/rakarrack-plus#StompBox"
#define STOMP_NAME "RakarrackPlus StompBox"
const int C_STOMP_PARAMETERS = 6;
enum Stomp_Index
{
Stomp_Level = 0,
Stomp_Tone,
Stomp_Mid,
Stomp_Bias,
Stomp_Gain,
Stomp_Mode
};
static const char *stomp_parameters[] =
{
strdup(NTS(Stomp_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Stomp_Tone).c_str()), "Tone", "HI",
strdup(NTS(Stomp_Mid).c_str()), "Mid", "MID",
strdup(NTS(Stomp_Bias).c_str()), "Bias", "LO",
strdup(NTS(Stomp_Gain).c_str()), "Gain", "GAIN",
strdup(NTS(Stomp_Mode).c_str()), "Mode", "MODE"
};
class StompBox : public Effect
{
public:
StompBox (int wave_res, int wave_upq, int wave_dnq, double sample_rate, uint32_t intermediate_bufsize);
~StompBox ();
void out (float * efxoutl, float * efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_STOMP_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return STOMPLV2_URI; };
virtual std::string get_name(int) {return STOMP_NAME; };
void initialize();
void clear_initialize();
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
private:
void setvolume (int value);
void init_mode (int value);
void init_tone ();
int WAVE_RES;
int WAVE_UPQ;
int WAVE_DNQ;
uint32_t PERIOD;
double fSAMPLE_RATE;
int Pvolume;
int Pgain;
int Phigh;
int Pmid;
int Plow;
int Pmode;
float gain, pre1gain, pre2gain, lowb, midb, highb, volume;
float LG, MG, HG, RGP2, RGPST, pgain;
float* interpbuf; //buffer for filters
AnalogFilter *linput, *lpre1, *lpre2, *lpost, *ltonehg, *ltonemd, *ltonelw;
AnalogFilter *rinput, *rpre1, *rpre2, *rpost, *rtonehg, *rtonemd, *rtonelw;
AnalogFilter *ranti, *lanti;
class Waveshaper *lwshape, *rwshape, *lwshape2, *rwshape2;
};
#endif
| 3,351
|
C++
|
.h
| 92
| 32.413043
| 107
| 0.700804
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,528
|
Looper.h
|
Stazed_rakarrack-plus/src/FX/Looper.h
|
/*
ZynAddSubFX - a software synthesizer
Looper.h - Looper Effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Ryan Billing & Josep Andreu
Reverse Echo by Transmogrifox
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LOOPER_H
#define LOOPER_H
#include "Effect.h"
#include "../metronome.h"
/**
* This is the number of parameters saved to file and presets.
* There are actually 18 parameters, but last 4 are not saved...
*/
const int C_LOOPER_PARAMETERS = 14;
enum Looper_Index
{
Looper_DryWet = 0,
Looper_Play,
Looper_Stop,
Looper_Record,
Looper_Clear,
Looper_Reverse,
Looper_Level_1,
Looper_Track_1,
Looper_Track_2,
Looper_AutoPlay,
Looper_Level_2,
Looper_Rec_1,
Looper_Rec_2,
Looper_Link,
Looper_Tempo, // not saved
Looper_Bar, // not saved
Looper_Metro, // not saved
Looper_M_S // not saved
};
class Looper :public Effect
{
public:
Looper (float size, double samplerate, uint32_t intermediate_bufsize);
~Looper ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void set_value (int npar, int value); // to set one from a preset
void changepar (int npar, int value);
int getpar (int npar);
int get_number_efx_parameters () {return C_LOOPER_PARAMETERS;};
void cleanuppt1 ();
void cleanuppt2 ();
void cleanup ();
void settempo(int value);
void setmvol(int value);
void getstate ();
int Pplay;
int Pstop;
int looper_bar;
int looper_qua;
int progstate[6];
private:
class metronome ticker;
float fSAMPLE_RATE;
unsigned int SAMPLE_RATE;
uint32_t PERIOD;
void initdelays ();
void setfade ();
void setbar(int value);
void timeposition(int value);
int set_len(int value);
int cal_len(int value);
void setvolume (int volume);
//Parameters
int Pvolume; //Mix
int Precord; //set to 1
int Pclear; //set to 1
int Preverse; //0 or 1
int Pfade1; //0...127// crossfade track1 & 2
int Pfade2;
int PT1;
int PT2;
int Pautoplay;
int Prec1;
int Prec2;
int Plink;
int Ptempo;
int Pbar;
int Pmetro;
int Pms;
int kl, kl2, rvkl, rvkl2, maxx_delay, fade, dl, dl2, first_time1, first_time2, rplaystate;
int barlen, looper_ts;
float *ldelay, *rdelay;
float *t2ldelay, *t2rdelay;
float oldl, oldr; //pt. lpf
float Srate_Attack_Coeff, track1gain, track2gain, fade1, fade2, pregain1, pregain2;
float mvol;
};
#endif
| 3,263
|
C++
|
.h
| 108
| 25.851852
| 94
| 0.688604
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,529
|
MIDIConverter.h
|
Stazed_rakarrack-plus/src/FX/MIDIConverter.h
|
/* tuneit.c -- Detect fundamental frequency of a sound
* Copyright (C) 2004, 2005 Mario Lang <mlang@delysid.org>
*
* Modified for rakarrack by Josep Andreu
* MIDIConverter.h MIDIConverter definitions
*
* This is free software, placed under the terms of the
* GNU General Public License, as published by the Free Software Foundation.
* Please see the file COPYING for details.
*/
#ifndef MIDICONVERTER_H_
#define MIDICONVERTER_H_
#include <math.h>
#include <stdlib.h>
#include <complex.h>
#include <fftw3.h>
#define MIDICLV2_URI "https://github.com/Stazed/rakarrack-plus#midi_converter"
const unsigned char EVENT_NOTE_OFF = 0x80;
const unsigned char EVENT_NOTE_ON = 0x90;
const unsigned char NOTE_OFF_VELOCITY = 64;
#ifdef LV2_SUPPORT
#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include"../lv2/rkrlv2.h"
struct _RKRLV2; // Forward declaration
#else
#include <jack/midiport.h>
#include <jack/ringbuffer.h>
#include <alsa/asoundlib.h>
#endif // LV2_SUPPORT
const int C_MIDICONV_PARAMETERS = 7;
enum MIDIConv_Index
{
MIDIConv_Gain = 0, // LV2 only
MIDIConv_Trigger,
MIDIConv_Velocity,
MIDIConv_Midi,
MIDIConv_Octave,
MIDIConv_FFT,
MIDIConv_Panic
};
class MIDIConverter
{
public:
MIDIConverter (char *jname, double sample_rate, uint32_t intermediate_bufsize);
~MIDIConverter ();
void out (float * efxoutl, float * efxoutr);
signed short int *schmittBuffer;
signed short int *schmittPointer;
const char **notes;
int note;
float nfreq, afreq, freq;
float TrigVal;
int cents;
void schmittFloat (float * efxoutl, float * efxoutr, float val_sum, float *freqs, float *lfreqs);
void fftFloat (float * efxoutl, float * efxoutr, float val_sum, float *freqs, float *lfreqs);
void setmidichannel (int channel);
void panic ();
void setTriggerAdjust (int val);
void setVelAdjust (int val);
void setOctAdjust(int val);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int channel;
int lanota;
int nota_actual;
int hay;
int preparada;
int ponla;
int velocity;
int Moctave;
uint32_t PERIOD;
float VelVal;
unsigned char midi_Note_Message[3];
private:
void displayFrequency (float freq, float val_sum, float *freqs, float *lfreqs);
void schmittInit (int size);
void schmittS16LE (signed short int *indata, float val_sum, float *freqs, float *lfreqs);
void schmittFree ();
//FFT
void fftInit (int size);
void fftMeasure (int overlap, float *indata, float val_sum, float *freqs, float *lfreqs);
void fftS16LE (signed short int *indata, float val_sum, float *freqs, float *lfreqs);
void fftFree ();
void send_Midi_Note (uint nota, float val_sum, bool is_On);
unsigned int blockSize;
unsigned int SAMPLE_RATE;
float fSAMPLE_RATE;
#ifdef LV2_SUPPORT
public:
void setGain(int val);
void lv2_update_params(uint32_t period);
void update_freqs(float val);
_RKRLV2* plug; // for access to forge_midimessage()
private:
float Input_Gain;
float FREQS[12];
float LFREQS[12];
float VAL_SUM;
float old_il_sum; // -50.0
float old_ir_sum; // -50.0
float val_il_sum;
float val_ir_sum;
int Pgain;
#else // LV2_SUPPORT
public:
jack_ringbuffer_t *m_buffSize;
jack_ringbuffer_t *m_buffMessage;
snd_seq_t *port;
private:
#endif
//Parametrii
int Pmidi;
int Poctave;
int Ppanic;
int Pvelocity;
int Ptrigger;
int Pfft;
float *fftSampleBuffer;
float *fftSample;
float *fftLastPhase;
int fftSize;
int fftFrameCount;
float *fftIn;
fftwf_complex *fftOut;
fftwf_plan fftPlan;
typedef struct Peak {
double freq;
double db;
Peak ():
freq(),
db() {}
} Peak;
};
#endif /*MIDICONVERTER_H_ */
| 3,924
|
C++
|
.h
| 135
| 24.925926
| 101
| 0.690317
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,530
|
Echotron.h
|
Stazed_rakarrack-plus/src/FX/Echotron.h
|
/*
Echotron.h - Convolution-based Echo Effect
Author: Ryan Billing & Josep Andreu
Adapted effect structure of ZynAddSubFX - a software synthesizer
Author: Nasca Octavian Paul
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ECHOTRON_H
#define ECHOTRON_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/EffectLFO.h"
#include "../EFX_common/delayline.h"
#include "../EFX_common/RBFilter.h"
#define ECHOTRONLV2_URI "https://github.com/Stazed/rakarrack-plus#Echotron"
#define ECHOTRON_NAME "RakarrackPlus Echotron"
#define ECHOTRON_F_SIZE 128 //Allow up to 150 points in the file
#define ECHOTRON_MAXFILTERS 32 //filters available
const int C_ECHOTRON_PARAMETERS = 16;
enum Echotron_Index
{
Echotron_DryWet = 0,
Echotron_Depth,
Echotron_LFO_Width,
Echotron_Taps,
Echotron_User_File,
Echotron_Tempo,
Echotron_Damp,
Echotron_LR_Cross,
Echotron_Set_File,
Echotron_LFO_Stereo,
Echotron_Feedback,
Echotron_Pan,
Echotron_Mod_Delay,
Echotron_Mod_Filter,
Echotron_LFO_Type,
Echotron_Filters
};
static const char *echotron_parameters[] =
{
strdup(NTS(Echotron_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Echotron_Depth).c_str()), "Filter Depth", "DEPTH",
strdup(NTS(Echotron_LFO_Width).c_str()), "LFO Width", "WIDTH",
strdup(NTS(Echotron_Taps).c_str()), "Number of Taps", "LENGTH",
strdup(NTS(Echotron_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Echotron_Damp).c_str()), "Dampening", "DAMP",
strdup(NTS(Echotron_LR_Cross).c_str()), "Left/Right Crossover", "LRC",
strdup(NTS(Echotron_LFO_Stereo).c_str()), "LFO L/R Delay", "STDF",
strdup(NTS(Echotron_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Echotron_Pan).c_str()), "Pan", "PAN",
strdup(NTS(Echotron_Mod_Delay).c_str()), "Modulate Delays", "MD",
strdup(NTS(Echotron_Mod_Filter).c_str()), "Modulate Filters", "MF",
strdup(NTS(Echotron_LFO_Type).c_str()), "LFO Type", "LFOTYPE",
strdup(NTS(Echotron_Filters).c_str()), "Activate Filters", "AF"
};
class DlyFile
{
public:
//arrays of parameters from text file:
double fPan[ECHOTRON_F_SIZE]; //1+Pan from text file
double fTime[ECHOTRON_F_SIZE];
double fLevel[ECHOTRON_F_SIZE];
double fLP[ECHOTRON_F_SIZE];
double fBP[ECHOTRON_F_SIZE];
double fHP[ECHOTRON_F_SIZE];
double fFreq[ECHOTRON_F_SIZE];
double fQ[ECHOTRON_F_SIZE];
int iStages[ECHOTRON_F_SIZE];
double subdiv_dmod;
double subdiv_fmod;
int f_qmode;
float rtime[ECHOTRON_F_SIZE];
float ltime[ECHOTRON_F_SIZE];
float ldata[ECHOTRON_F_SIZE];
float rdata[ECHOTRON_F_SIZE];
int fLength;
char Filename[128];
std::string Description;
DlyFile():
fPan(),
fTime(),
fLevel(),
fLP(),
fBP(),
fHP(),
fFreq(),
fQ(),
iStages(),
subdiv_dmod(0.0),
subdiv_fmod(0.0),
f_qmode(0),
rtime(),
ltime(),
ldata(),
rdata(),
fLength(0.0),
Filename(),
Description() {}
};
#define INVALID_DELAY_FILE_RANGE -1
enum Echotron_file_errors
{
Dly_Open = 4,
Dly_Pan,
Dly_Time,
Dly_Level,
Dly_LP,
Dly_BP,
Dly_HP,
Dly_Freq,
Dly_Q,
Dly_Stages
};
class Echotron :public Effect
{
public:
Echotron (double sample_rate, uint32_t intermediate_bufsize);
~Echotron ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_ECHOTRON_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return ECHOTRONLV2_URI; };
virtual std::string get_name(int) {return ECHOTRON_NAME; };
void initialize();
void clear_initialize();
int setfile (int value);
bool check_delay_file_ranges(double value, int item);
DlyFile loadfile(char* path);
void applyfile(const DlyFile &);
int get_file_length() {return File.fLength;};
char *get_file_name() {return File.Filename;};
void set_user_files(const std::vector<User_Files> &dly_files){DLY_Files = dly_files;};
char Filename[128];
DlyFile File;
int error;
private:
void setvolume (int _Pvolume);
void setpanning (int value);
void sethidamp (int _Phidamp);
void setfb(int value);
void init_params();
void modulate_delay();
void modulate_filters();
DlyFile loaddefault();
std::vector<User_Files> DLY_Files;
float fSAMPLE_RATE;
uint32_t PERIOD;
float fPERIOD;
//User input parameters
int Pvolume; //This is master wet/dry mix like other FX...but I am finding it is not useful
int Ppanning; //Panning
int Plrcross; // L/R Mixing //
int Phidamp;
int Puser; //0,1//
int Ptempo; //Tempo, BPM//For stretching reverb responses
int Filenum;
int Pfb; //-64 ... 64// amount of feedback
int Pdepth;
int Pwidth;
int Pfilters; //0 or 1// use or don't use filters in delay line
int Pmodfilts; //0 or 1// apply LFO to filter freqs
int Pmoddly; //0 or 1// apply LFO to delay time
int Pstdiff;
int Plength;
int Llength; //limited length
int offset;
int maxx_size;
//arrays of parameters from text file:
/*
float fPan[ECHOTRON_F_SIZE]; //1+Pan from text file
float fTime[ECHOTRON_F_SIZE];
float fLevel[ECHOTRON_F_SIZE];
float fLP[ECHOTRON_F_SIZE];
float fBP[ECHOTRON_F_SIZE];
float fHP[ECHOTRON_F_SIZE];
float fFreq[ECHOTRON_F_SIZE];
float fQ[ECHOTRON_F_SIZE];
int iStages[ECHOTRON_F_SIZE];
float subdiv_dmod;
float subdiv_fmod;
int f_qmode;
float rtime[ECHOTRON_F_SIZE];
float ltime[ECHOTRON_F_SIZE];
float ldata[ECHOTRON_F_SIZE];
float rdata[ECHOTRON_F_SIZE];
*/
//end text configurable parameters
int initparams;
float ldmod, rdmod, oldldmod, oldrdmod, interpl, interpr;
float dlyrange;
float width, depth;
// float lpanning, rpanning, hidamp, alpha_hidamp, convlength;
float lpanning, rpanning, hidamp;
delayline *lxn, *rxn;
// float level,fb, rfeedback, lfeedback,levpanl,levpanr, lrcross, ilrcross;
float fb, rfeedback, lfeedback, lrcross, ilrcross;
float tempo_coeff;
EffectLFO *lfo;
EffectLFO *dlfo;
class AnalogFilter *lpfl, *lpfr; //filters
float* interpbuf; //buffer for filters
struct filterbank
{
float sfreq, sq,sLP,sBP,sHP, sStg;
class RBFilter *l, *r;
filterbank():
sfreq(),
sq(),
sLP(),
sBP(),
sHP(),
sStg(),
l(),
r() {}
} filterbank[ECHOTRON_MAXFILTERS];
#ifdef LV2_SUPPORT
char* FILENAME; // for lv2 if need to re-initialize and reset .dly file
#endif // LV2
};
#endif
| 7,804
|
C++
|
.h
| 238
| 27.621849
| 95
| 0.66342
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,531
|
Dual_Flange.h
|
Stazed_rakarrack-plus/src/FX/Dual_Flange.h
|
/*
Rakarrack Audio FX
Dual_Flange.h - Super Flanger
Copyright (C) 2010 Ryan Billing
Authors:
Ryan Billing (a.k.a Transmogrifox) -- Signal Processing
Copyright (C) 2010 Ryan Billing
Nasca Octavian Paul -- Remnants of ZynAddSubFX Echo.h structure and utility routines common to ZynSubFX source
Copyright (C) 2002-2005 Nasca Octavian Paul
Higher intensity flanging accomplished by picking two points out of the delay line to create a wider notch filter.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DUAL_FLANGE_H
#define DUAL_FLANGE_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#include "../EFX_common/delayline.h"
#define DFLANGELV2_URI "https://github.com/Stazed/rakarrack-plus#Dual_Flange"
#define DFLANGE_NAME "RakarrackPlus Dual Flange"
const int C_DFLANGE_PARAMETERS = 15;
enum DFlange_Index
{
DFlange_DryWet = 0,
DFlange_Pan,
DFlange_LR_Cross,
DFlange_Depth,
DFlange_Width,
DFlange_Offset,
DFlange_Feedback,
DFlange_LPF,
DFlange_Subtract,
DFlange_Zero,
DFlange_LFO_Tempo,
DFlange_LFO_Stereo,
DFlange_LFO_Type,
DFlange_LFO_Random,
DFlange_Intense
};
static const char *dflange_parameters[] =
{
strdup(NTS(DFlange_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(DFlange_Pan).c_str()), "Pan", "PAN",
strdup(NTS(DFlange_LR_Cross).c_str()), "Left/Right Crossover", "LRC",
strdup(NTS(DFlange_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(DFlange_Width).c_str()), "Sweep Width", "WIDTH",
strdup(NTS(DFlange_Offset).c_str()), "Offset Delays", "OFFS",
strdup(NTS(DFlange_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(DFlange_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(DFlange_Subtract).c_str()), "Subtract", "SUB",
strdup(NTS(DFlange_Zero).c_str()), "Sweep Through Zero", "THZ",
strdup(NTS(DFlange_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(DFlange_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(DFlange_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(DFlange_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(DFlange_Intense).c_str()), "Intense", "INTENSE"
};
class Dflange : public Effect
{
public:
Dflange (double sample_rate, uint32_t intermediate_bufsize);
~Dflange ();
void out (float * efxoutl, float * efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_DFLANGE_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return DFLANGELV2_URI; };
virtual std::string get_name(int) {return DFLANGE_NAME; };
private:
float fSAMPLE_RATE;
uint32_t PERIOD;
void setvolume(int value);
//Parameters
int Pwetdry; // 0 //Wet/Dry mix. Range -64 to 64
int Ppanning; // 1 //Panning. Range -64 to 64
int Plrcross; // 2 //L/R Mixing. Range 0 to 127
int Pdepth; // 3 //Max delay deviation expressed as frequency of lowest frequency notch. Min = 20, Max = 4000
int Pwidth; // 4 //LFO amplitude. Range 0 to 16000 (Hz)
int Poffset; // 5 //Offset of notch 1 to notch 2. Range 0 to 100 (percent)
int Pfb; // 6 //Feedback parameter. Range -64 to 64
int Phidamp; // 7 //Lowpass filter delay line. Range 20 to 20000 (Hz)
int Psubtract; // 8 //Subtract wet/dry instead of add. Nonzero is true
int Pzero; // 9 //Enable through-zero flanging, Nonzero is true
// 10 //LFO Speed
// 11 //LFO stereo diff
// 12 //LFO type
// 13 //LFO Randomness
int Pintense; // 14 //Intense Mode
float wet, dry; //Wet/Dry mix.
float lpan, rpan; //Panning.
float flrcross, frlcross; // L/R Mixing.
float fdepth; //Max delay deviation expressed as frequency of lowest frequency notch. Min = 20, Max = 15000
float fwidth; //LFO amplitude.
float foffset; // Offset of notch 1 to notch 2. Range 0 to 1.0
float ffb; //Feedback parameter. Range -0.99 to 0.99
float fhidamp; //Lowpass filter delay line. Range 20 to 20000 (Hz)
float fsubtract; //Subtract wet/dry instead of add. Nonzero is true
float logmax;
//Internally used variables
int maxx_delay;
int kl, kr, zl, zr;
int zcenter;
float l, r, ldl, rdl, zdr, zdl;
float rflange0, rflange1, lflange0, lflange1, oldrflange0, oldrflange1, oldlflange0, oldlflange1;
float period_const, base, ibase;
float *ldelay, *rdelay, *zldelay, *zrdelay;
float oldl, oldr; //pt. lpf
float rsA, rsB, lsA, lsB; //Audio sample at given delay
delayline *ldelayline0, *rdelayline0, *ldelayline1, *rdelayline1;
EffectLFO *lfo; //lfo Flanger
};
#endif
| 5,648
|
C++
|
.h
| 129
| 39.379845
| 116
| 0.68929
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,532
|
Chorus.h
|
Stazed_rakarrack-plus/src/FX/Chorus.h
|
/*
ZynAddSubFX - a software synthesizer
Chorus.h - Chorus and Flange effects
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef CHORUS_H
#define CHORUS_H
#include "../EFX_common/EffectLFO.h"
#include "../EFX_common/delayline.h"
#include "Effect.h"
#define CHORUSLV2_URI "https://github.com/Stazed/rakarrack-plus#chor"
#define CHORUS_NAME "RakarrackPlus Chorus"
const int C_CHORUS_PARAMETERS = 13;
enum Chorus_Index
{
Chorus_DryWet = 0,
Chorus_Pan,
Chorus_LFO_Tempo,
Chorus_LFO_Random,
Chorus_LFO_Type,
Chorus_LFO_Stereo,
Chorus_Depth,
Chorus_Delay,
Chorus_Feedback,
Chorus_LR_Cross,
Chorus_SKIP_Flange_10,
Chorus_Subtract,
Chorus_Intense
};
static const char *chorus_parameters[] =
{
strdup(NTS(Chorus_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Chorus_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Chorus_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Chorus_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(Chorus_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(Chorus_LFO_Stereo).c_str()), "LFO L/R Delay", "WIDTH",
strdup(NTS(Chorus_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(Chorus_Delay).c_str()), "Delay", "DELAY",
strdup(NTS(Chorus_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Chorus_LR_Cross).c_str()), "Left/Right Crossover", "LRCR",
strdup(NTS(Chorus_Subtract).c_str()), "Subtract", "SUB",
strdup(NTS(Chorus_Intense).c_str()), "Intense", "INTENSE"
};
class Chorus :public Effect
{
public:
Chorus (double sample_rate, uint32_t intermediate_bufsize);
virtual ~Chorus ();
void out (float * efxoutl, float * efxoutr);
virtual void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_CHORUS_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return CHORUSLV2_URI; };
virtual std::string get_name(int) {return CHORUS_NAME; };
float fSAMPLE_RATE;
uint32_t PERIOD;
float fPERIOD;
//Parametrii Chorus
EffectLFO* lfo; //lfo-ul chorus
int Pvolume;
int Ppanning;
int Pdepth; //the depth of the Chorus(ms)
int Pdelay; //the delay (ms)
int Pfb; //feedback
int Plrcross; //feedback
int Pflangemode; //how the LFO is scaled, to result chorus or flange
int Poutsub; //if I wish to substract the output instead of the adding it
//Control Parametrii
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setdepth (int _Pdepth);
void setdelay (int _Pdelay);
void setfb (int _Pfb);
void setlrcross (int _Plrcross);
//Valorile interne
int maxdelay;
int dlk, drk, dlhi, dlhi2;
int awesome_mode;
float depth, delay, fb, lrcross, panning, oldr, oldl;
float dl1, dl2, dr1, dr2, lfol, lfor;
float *delayl, *delayr;
float getdelay (float xlfo);
float dllo, mdel;
class delayline *ldelay, *rdelay;
};
#endif
| 3,952
|
C++
|
.h
| 106
| 33.028302
| 79
| 0.695151
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,533
|
Alienwah.h
|
Stazed_rakarrack-plus/src/FX/Alienwah.h
|
/*
ZynAddSubFX - a software synthesizer
Alienwah.h - "AlienWah" effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ALIENWAH_H
#define ALIENWAH_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#define ALIENLV2_URI "https://github.com/Stazed/rakarrack-plus#awha"
#define ALIEN_NAME "RakarrackPlus AlienWah"
const int C_ALIENWAH_PARAMETERS = 11;
enum AlienWah_Index
{
Alien_DryWet = 0,
Alien_Pan,
Alien_LFO_Tempo,
Alien_LFO_Random,
Alien_LFO_Type,
Alien_LFO_Stereo,
Alien_Depth,
Alien_Feedback,
Alien_Delay,
Alien_LR_Cross,
Alien_Phase
};
static const char *alien_parameters[] =
{
strdup(NTS(Alien_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Alien_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Alien_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Alien_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(Alien_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(Alien_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(Alien_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(Alien_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Alien_Delay).c_str()), "Delay", "DELAY",
strdup(NTS(Alien_LR_Cross).c_str()), "Left/Right Crossover", "LRCR",
strdup(NTS(Alien_Phase).c_str()), "Phase", "PHASE"
};
struct COMPLEXTYPE
{
float a, b;
COMPLEXTYPE():
a(),
b() {}
};
class Alienwah : public Effect
{
public:
Alienwah (double sample_rate, uint32_t intermediate_bufsize);
~Alienwah ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_ALIENWAH_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return ALIENLV2_URI; };
virtual std::string get_name(int) {return ALIEN_NAME; };
private:
float fPERIOD;
uint32_t PERIOD;
//Parametrii Alienwah
int Pvolume;
int Ppanning;
int Pdepth; //the depth of the Alienwah
int Pfb; //feedback
int Plrcross; //feedback
int Pdelay;
int Pphase;
int oldk;
int oldpdelay;
//Control Parametrii
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setdepth (int _Pdepth);
void setfb (int _Pfb);
void setlrcross (int _Plrcross);
void setdelay (int _Pdelay);
void setphase (int _Pphase);
EffectLFO *lfo; //lfo-ul Alienwah
//Valorile interne
float panning, fb, depth, lrcross, phase;
struct COMPLEXTYPE oldl[MAX_ALIENWAH_DELAY], oldr[MAX_ALIENWAH_DELAY];
COMPLEXTYPE oldclfol, oldclfor;
};
#endif
| 3,637
|
C++
|
.h
| 105
| 30.247619
| 79
| 0.692043
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,534
|
Effect.h
|
Stazed_rakarrack-plus/src/FX/Effect.h
|
/*
rakarrack - Audio effects software
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EFFECT_H
#define EFFECT_H
#include "../global.h"
#include "../EFX_common/FPreset.h"
struct User_Files
{
std::string User_File_Name; // Full path
std::string User_File_Menu_Name; // File name w/o extension and with *
std::string User_File_Name_Clean; // File name w/o path
};
enum
{
NON_MIXER_XT = 0,
CARLA
};
class Effect
{
public:
Effect (double, uint32_t period) :
period_master(period), outvolume(0.5f), Ppreset(0), Fpre(NULL) {};
// Distortion, Overdrive, Derelict, DistBand, StompBox, Convolotron, Reverbtron
Effect (int, int, int, double, uint32_t period) :
period_master(period), outvolume(0.5f), Ppreset(0), Fpre(NULL) {};
// Harmonizer, Sequence, Shifter, StereoHarm
Effect (long int, int, int, int, double, uint32_t period) :
period_master(period), outvolume(0.5f), Ppreset(0), Fpre(NULL) {};
// Looper
Effect (float, double, uint32_t period) :
period_master(period), outvolume(0.5f), Ppreset(0), Fpre(NULL) {};
// Vocoder
Effect (float *, int, int, int, int, double, uint32_t period) :
period_master(period), outvolume(0.5f), Ppreset(0), Fpre(NULL) {};
virtual ~ Effect () {};
virtual void setpreset (int) = 0;
virtual void changepar (int, int) = 0;
virtual int getpar (int) = 0;
virtual void out (float *, float *) = 0;
virtual void cleanup () = 0;
virtual int get_number_efx_parameters () = 0;
virtual void set_random_parameters() {};
virtual void Dry_Wet_Mix(int efx_index, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void Vol2_Efx(float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void Vol3_Efx(float *efxoutl, float *efxoutr, float *smpl, float *smpr);
#ifdef LV2_SUPPORT
virtual void lv2_update_params(uint32_t) = 0;
#endif // LV2
virtual void LV2_parameters(std::string &, int) {};
virtual std::string get_URI(int) { return ""; };
virtual std::string get_name(int) { return ""; };
void Carla_LV2_port(std::string &, int index, int value, const std::string &name, const std::string &symbol);
uint32_t period_master;
float outvolume;
int Ppreset;
class FPreset *Fpre;
};
#endif
| 2,978
|
C++
|
.h
| 70
| 38.042857
| 113
| 0.685953
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,535
|
WahWah.h
|
Stazed_rakarrack-plus/src/FX/WahWah.h
|
/*
ZynAddSubFX - a software synthesizer
WahWah.h - "WahWah" effect and others
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Renamed from DynamicFilter.h on 4/19/2020 by stazed
#ifndef WAHWAH_H
#define WAHWAH_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#include "../EFX_common/Filter.h"
#define WAHLV2_URI "https://github.com/Stazed/rakarrack-plus#wha"
#define WAH_NAME "RakarrackPlus WahWah"
const int C_WAHWAH_PARAMETERS = 11;
enum WahWah_Index
{
WahWah_DryWet = 0,
WahWah_Pan,
WahWah_LFO_Tempo,
WahWah_LFO_Random,
WahWah_LFO_Type,
WahWah_LFO_Stereo,
WahWah_Depth,
WahWah_Sense,
WahWah_ASI,
WahWah_Smooth,
WahWah_Mode
};
static const char *wah_parameters[] =
{
strdup(NTS(WahWah_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(WahWah_Pan).c_str()), "Panning", "PAN",
strdup(NTS(WahWah_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(WahWah_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(WahWah_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(WahWah_LFO_Stereo).c_str()), "LFO L/R Delay", "WIDTH",
strdup(NTS(WahWah_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(WahWah_Sense).c_str()), "Sensitivity", "SENSE",
strdup(NTS(WahWah_ASI).c_str()), "Invert", "INV",
strdup(NTS(WahWah_Smooth).c_str()), "Smooth", "SMOOTH",
strdup(NTS(WahWah_Mode).c_str()), "Filter Type", "MODE"
};
class WahWah : public Effect
{
public:
WahWah (double sample_rate, uint32_t intermediate_bufsize);
~WahWah ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_WAHWAH_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return WAHLV2_URI; };
virtual std::string get_name(int) {return WAH_NAME; };
private:
uint32_t PERIOD;
double fSAMPLE_RATE;
//Parametrii WahWah
int Pvolume;
int Ppanning;
int Pdepth; //the depth of the lfo of the WahWah
int Pampsns; //how the filter varies according to the input amplitude
int Pampsnsinv; //if the filter freq is lowered if the input amplitude rises
int Pampsmooth; //how smooth the input amplitude changes the filter
int Pmode; //settings of filters
//Control Parametrii
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setdepth (int _Pdepth);
void setampsns (int _Pampsns);
void reinitfilter ();
//Valorile interne
float panning, depth, ampsns, ampsmooth;
float ms1, ms2, ms3, ms4; //mean squares
EffectLFO* lfo; //lfo-ul WahWah
class Filter *filterl, *filterr;
class FilterParams *filterpars;
};
#endif
| 3,703
|
C++
|
.h
| 97
| 34.051546
| 80
| 0.702408
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,536
|
Distorsion.h
|
Stazed_rakarrack-plus/src/FX/Distorsion.h
|
/*
ZynAddSubFX - a software synthesizer
Distorsion.h - Distorsion Effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu & Hernan Ordiales & Ryan Billing
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DISTORSION_H
#define DISTORSION_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/Waveshaper.h"
#define DISTLV2_URI "https://github.com/Stazed/rakarrack-plus#dist"
#define DIST_NAME "RakarrackPlus Distorsion"
const int C_DIST_PARAMETERS = 13;
enum Dist_Index
{
Dist_DryWet = 0,
Dist_Pan,
Dist_LR_Cross,
Dist_Drive,
Dist_Level,
Dist_Type,
Dist_Negate,
Dist_LPF,
Dist_HPF,
Dist_Stereo,
Dist_Prefilter,
Dist_SKIP_11,
Dist_Suboctave
};
static const char *dist_parameters[] =
{
strdup(NTS(Dist_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Dist_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Dist_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(Dist_Drive).c_str()), "Drive", "DRIVE",
strdup(NTS(Dist_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Dist_Type).c_str()), "Type", "TYPE",
strdup(NTS(Dist_Negate).c_str()), "Negate (Polarity Switch)", "NEG",
strdup(NTS(Dist_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(Dist_HPF).c_str()), "Highpass Filter", "HPF",
strdup(NTS(Dist_Stereo).c_str()), "Stereo", "STEREO",
strdup(NTS(Dist_Prefilter).c_str()), "Prefilter", "PREFILTER",
strdup(NTS(Dist_Suboctave).c_str()), "Suboctave", "OCT"
};
class Distorsion :public Effect
{
public:
Distorsion (int wave_res, int wave_upq, int wave_dnq, double samplerate, uint32_t intermediate_bufsize);
virtual ~Distorsion ();
void out (float * efxoutl, float * efxoutr);
virtual void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_DIST_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return DISTLV2_URI; };
virtual std::string get_name(int) {return DIST_NAME; };
void applyfilters (float * efxoutl, float * efxoutr);
void initialize ();
void clear_initialize();
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
float *octoutl;
float *octoutr;
private:
uint32_t PERIOD;
double fSAMPLE_RATE;
int WAVE_RES;
int WAVE_UPQ;
int WAVE_DNQ;
//Parametrii
int Pvolume; //Volumul or E/R
int Ppanning; //Panning
int Plrcross; // L/R Mixing
int Pdrive; //the input amplification
int Plevel; //the ouput amplification
int Ptype; //Distorsion type
int Pnegate; //if the input is negated
int Plpf; //lowpass filter
int Phpf; //highpass filter
int Pstereo; //0=mono,1=stereo
int Pprefiltering; //if you want to do the filtering before the distorsion
int Poctave; //mix sub octave
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setlrcross (int _Plrcross);
void setoctave (int _Poctave);
void setlpf (int value);
void sethpf (int value);
//Parametrii reali
float panning, lrcross, octave_memoryl, togglel, octave_memoryr,toggler,octmix;
AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr, *blockDCl, *blockDCr, *DCl, *DCr;
class Waveshaper *dwshapel, *dwshaper;
float * interpbuf;//buffer for filters
};
#endif
| 4,346
|
C++
|
.h
| 115
| 33.434783
| 108
| 0.696203
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,537
|
DistBand.h
|
Stazed_rakarrack-plus/src/FX/DistBand.h
|
/*
DistBand.h - Distorsion Effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
ZynAddSubFX - a software synthesizer
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Renamed from MBDist.h on 4/18/2020 by stazed.
#ifndef DISTBAND_H
#define DISTBAND_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/Waveshaper.h"
#define DISTBANDLV2_URI "https://github.com/Stazed/rakarrack-plus#DistBand"
#define DISTBAND_NAME "RakarrackPlus DistBand"
const int C_DBAND_PARAMETERS = 15;
enum DistBand_Index
{
DistBand_DryWet = 0,
DistBand_Pan,
DistBand_LR_Cross,
DistBand_Drive,
DistBand_Level,
DistBand_Type_Low,
DistBand_Type_Mid,
DistBand_Type_Hi,
DistBand_Gain_Low,
DistBand_Gain_Mid,
DistBand_Gain_Hi,
DistBand_Negate,
DistBand_Cross_1,
DistBand_Cross_2,
DistBand_Stereo
};
static const char *distband_parameters[] =
{
strdup(NTS(DistBand_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(DistBand_Pan).c_str()), "Panning", "PAN",
strdup(NTS(DistBand_LR_Cross).c_str()), "Left/Right Crossover", "LRCr",
strdup(NTS(DistBand_Drive).c_str()), "Drive", "DRIVE",
strdup(NTS(DistBand_Level).c_str()), "Level", "LEVEL",
strdup(NTS(DistBand_Type_Low).c_str()), "Low Band Type", "TYPEL",
strdup(NTS(DistBand_Type_Mid).c_str()), "Mid Band Type", "TYPEM",
strdup(NTS(DistBand_Type_Hi).c_str()), "High Band Type", "TYPEH",
strdup(NTS(DistBand_Gain_Low).c_str()), "Low Gain", "LVOL",
strdup(NTS(DistBand_Gain_Mid).c_str()), "Mid Gain", "MVOL",
strdup(NTS(DistBand_Gain_Hi).c_str()), "High Gain", "HVOL",
strdup(NTS(DistBand_Negate).c_str()), "Negate (Polarity Switch)", "NEG",
strdup(NTS(DistBand_Cross_1).c_str()), "Low/Mid Crossover", "LMCR",
strdup(NTS(DistBand_Cross_2).c_str()), "Mid/High Crossover", "MHCR",
strdup(NTS(DistBand_Stereo).c_str()), "Stereo", "STEREO"
};
class DistBand : public Effect
{
public:
DistBand (int wave_res, int wave_upq, int wave_dnq, double sample_rate, uint32_t intermediate_bufsize);
~DistBand ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_DBAND_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return DISTBANDLV2_URI; };
virtual std::string get_name(int) {return DISTBAND_NAME; };
void initialize ();
void clear_initialize();
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
private:
int WAVE_RES;
int WAVE_UPQ;
int WAVE_DNQ;
uint32_t PERIOD;
double fSAMPLE_RATE;
float *lowl;
float *lowr;
float *midl;
float *midr;
float *highl;
float *highr;
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setlrcross (int _Plrcross);
void setCross1 (int value);
void setCross2 (int value);
//Parametrii
int Pvolume; //Volumul or E/R
int Ppanning; //Panning
int Plrcross; // L/R Mixing
int Pdrive; //the input amplification
int Plevel; //the ouput amplification
int PtypeL;
int PtypeM;
int PtypeH;
int PvolL;
int PvolM;
int PvolH;
int PdriveL;
int PdriveM;
int PdriveH;
//DistBand type
int Pnegate; //if the input is negated
int Cross1; //lowpass filter
int Cross2; //highpass filter
int Pstereo; //0=mono,1=stereo
//Parametrii reali
float panning, lrcross;
float volL,volM,volH;
AnalogFilter *lpf1l, *lpf1r, *hpf1l, *hpf1r;
AnalogFilter *lpf2l, *lpf2r, *hpf2l, *hpf2r;
AnalogFilter *DCl, *DCr;
float* interpbuf; //buffer for filters
class Waveshaper *mbwshape1l, *mbwshape2l, *mbwshape3l;
class Waveshaper *mbwshape1r, *mbwshape2r, *mbwshape3r;
};
#endif
| 4,838
|
C++
|
.h
| 134
| 31.723881
| 107
| 0.691731
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,538
|
Pan.h
|
Stazed_rakarrack-plus/src/FX/Pan.h
|
/*
rakarrack - a guitar effects software
pan.h - Auto/Pan - Extra stereo definitions
Copyright (C) 2008-2010 Josep Andreu
Author: Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef AUTOPAN_H
#define AUTOPAN_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#define PANLV2_URI "https://github.com/Stazed/rakarrack-plus#pan"
#define PAN_NAME "RakarrackPlus Pan"
const int C_PAN_PARAMETERS = 9;
enum Pan_Index
{
Pan_DryWet = 0,
Pan_Pan,
Pan_LFO_Tempo,
Pan_LFO_Random,
Pan_LFO_Type,
Pan_LFO_Stereo,
Pan_Ex_St_Amt,
Pan_AutoPan,
Pan_Enable_Extra
};
static const char *pan_parameters[] =
{
strdup(NTS(Pan_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Pan_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Pan_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Pan_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(Pan_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(Pan_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(Pan_Ex_St_Amt).c_str()), "Extra Stereo Amount", "EXTRA_AMOUNT",
strdup(NTS(Pan_AutoPan).c_str()), "Autopan", "AUTO",
strdup(NTS(Pan_Enable_Extra).c_str()), "Extra Stereo Enable", "EXTRA_ON"
};
class Pan : public Effect
{
public:
Pan (double sample_rate, uint32_t intermediate_bufsize);
~Pan ();
void out (float *efxoutl, float *efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_PAN_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return PANLV2_URI; };
virtual std::string get_name(int) {return PAN_NAME; };
private:
uint32_t PERIOD;
float fPERIOD;
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void setextra (int _Pextra);
int Pvolume;
int Ppanning;
int Pextra;
int PAutoPan;
int PextraON;
float dvalue,cdvalue,sdvalue;
float panning, mul;
float lfol, lfor;
float ll, lr;
EffectLFO* lfo;
};
#endif
| 2,881
|
C++
|
.h
| 84
| 30.511905
| 80
| 0.695495
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,539
|
Vibe.h
|
Stazed_rakarrack-plus/src/FX/Vibe.h
|
/*
rakarrack - a guitar effects software
Vibe.h - Vibe Effect definitions
Copyright (C) 2008-2010 Ryan Billing
Author: Josep Andreu & Ryan Billing
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef Vibe_H
#define Vibe_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#define VIBELV2_URI "https://github.com/Stazed/rakarrack-plus#Vibe"
#define VIBE_NAME "RakarrackPlus Vibe"
//#define VIBE_INLINE 1 // uncomment for inline
const int C_VIBE_PARAMETERS = 11;
enum Vibe_Index
{
Vibe_Width = 0,
Vibe_LFO_Tempo,
Vibe_LFO_Random,
Vibe_LFO_Type,
Vibe_LFO_Stereo,
Vibe_Pan,
Vibe_DryWet,
Vibe_Feedback,
Vibe_Depth,
Vibe_LR_Cross,
Vibe_Stereo
};
static const char *vibe_parameters[] =
{
strdup(NTS(Vibe_Width).c_str()), "Width", "WIDTH",
strdup(NTS(Vibe_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Vibe_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(Vibe_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(Vibe_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(Vibe_Pan).c_str()), "Pan", "PAN",
strdup(NTS(Vibe_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Vibe_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(Vibe_Depth).c_str()), "Depth", "DEPTH",
strdup(NTS(Vibe_LR_Cross).c_str()), "Left/Right Crossover", "LRCR",
strdup(NTS(Vibe_Stereo).c_str()), "Stereo", "STEREO"
};
class Vibe : public Effect
{
public:
Vibe (double sample_rate, uint32_t intermediate_bufsize);
~Vibe ();
void out (float * efxoutl, float * efxoutr);
void setvolume(int value);
void setpanning(int value);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_VIBE_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return VIBELV2_URI; };
virtual std::string get_name(int) {return VIBE_NAME; };
private:
uint32_t PERIOD;
float cSAMPLE_RATE;
float fSAMPLE_RATE;
int Pwidth;
int Pfb;
int Plrcross;
int Pdepth;
int Ppanning;
int Pvolume;
int Pstereo;
float fwidth;
float fdepth;
float rpanning, lpanning;
float flrcross, fcross;
float fb;
float Ra, Rb, b, dTC, dRCl, dRCr, lampTC, ilampTC, minTC, alphal, alphar, stepl, stepr, oldstepl, oldstepr;
float fbr, fbl;
float dalphal, dalphar;
float lstep,rstep;
// float cperiod;
float gl, oldgl;
float gr, oldgr;
class fparams
{
public:
float x1;
float y1;
//filter coefficients
float n0;
float n1;
float d0;
float d1;
fparams():
x1(),
y1(),
n0(),
n1(),
d0(),
d1() {}
void clear ()
{
x1 = y1 = 0;
}
} vc[8], vcvo[8], ecvc[8], vevo[8], bootstrap[8];
float vibefilter(float data, fparams *ftype, int stage) const;
void init_vibes();
void modulate(float ldrl, float ldrr);
float bjt_shape(float data) const;
float R1;
float Rv;
float C2;
float C1[8];
float beta; //transistor forward gain.
float gain, k;
float oldcvolt[8] ;
float en1[8], en0[8], ed1[8], ed0[8];
float cn1[8], cn0[8], cd1[8], cd0[8];
float ecn1[8], ecn0[8], ecd1[8], ecd0[8];
float on1[8], on0[8], od1[8], od0[8];
EffectLFO* lfo;
};
#endif
| 4,290
|
C++
|
.h
| 136
| 26.360294
| 111
| 0.646169
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,540
|
Infinity.h
|
Stazed_rakarrack-plus/src/FX/Infinity.h
|
/*
Rakarrack Guitar Effects Processor
InfiniT : Infinitely rising & falling filter effect
Author: Ryan Billing (aka Transmogrifox)
Copyright (C) 2010
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef INFINITY_H
#define INFINITY_H
#include "Effect.h"
#include "../EFX_common/RBFilter.h"
#define INFLV2_URI "https://github.com/Stazed/rakarrack-plus#Infinity"
#define INF_NAME "RakarrackPlus Infinity"
#define NUM_INF_BANDS 8
const int C_INFINITY_PARAMETERS = 18;
enum Infinity_Index
{
Infinity_DryWet = 0,
Infinity_Band_1,
Infinity_Band_2,
Infinity_Band_3,
Infinity_Band_4,
Infinity_Band_5,
Infinity_Band_6,
Infinity_Band_7,
Infinity_Band_8,
Infinity_Resonance,
Infinity_Start,
Infinity_End,
Infinity_Tempo,
Infinity_LR_Delay,
Infinity_Subdivision,
Infinity_AutoPan,
Infinity_Reverse,
Infinity_Stages
};
static const char *inf_parameters[] =
{
strdup(NTS(Infinity_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Infinity_Band_1).c_str()), "Band 1 Gain", "B1",
strdup(NTS(Infinity_Band_2).c_str()), "Band 2 Gain", "B2",
strdup(NTS(Infinity_Band_3).c_str()), "Band 3 Gain", "B3",
strdup(NTS(Infinity_Band_4).c_str()), "Band 4 Gain", "B4",
strdup(NTS(Infinity_Band_5).c_str()), "Band 5 Gain", "B5",
strdup(NTS(Infinity_Band_6).c_str()), "Band 6 Gain", "B6",
strdup(NTS(Infinity_Band_7).c_str()), "Band 7 Gain", "B7",
strdup(NTS(Infinity_Band_8).c_str()), "Band 8 Gain", "B8",
strdup(NTS(Infinity_Resonance).c_str()), "Resonance", "RES",
strdup(NTS(Infinity_Start).c_str()), "Sweep Start", "START",
strdup(NTS(Infinity_End).c_str()), "Sweep End", "END",
strdup(NTS(Infinity_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Infinity_LR_Delay).c_str()), "Sweep L/R Delay", "STDF",
strdup(NTS(Infinity_Subdivision).c_str()), "Sweep Tempo Subdivision", "SUBD",
strdup(NTS(Infinity_AutoPan).c_str()), "AutoPan Amount", "AUTOPAN",
strdup(NTS(Infinity_Reverse).c_str()), "Reverse Left Channel Sweep", "REV",
strdup(NTS(Infinity_Stages).c_str()), "Stages", "STAGE"
};
class Infinity : public Effect
{
public:
Infinity (double sample_rate, uint32_t intermediate_bufsize);
~Infinity ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_INFINITY_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return INFLV2_URI; };
virtual std::string get_name(int) {return INF_NAME; };
void initialize();
void clear_initialize();
private:
void setvolume (int _Pvolume);
void adjustfreqs();
void oscillator();
void reinitfilter ();
void setq ();
float fSAMPLE_RATE;
uint32_t PERIOD;
int Pvolume; //For wet/dry mix // "Wet/Dry"
int Pb[NUM_INF_BANDS]; //Pbx -64 to 64// "Band" each label "1" through "8" adjusts mix of each filter band
int Pq; //-64 to 64// "Res." filter resonance
int Pstartfreq; //0 to 127// "Start" where the filter starts
int Pendfreq; //0 to 127// "End" when the filter ends
int Prate; //BPM// "Tempo" how fast it sweeps
int Pstdf; //filter bands offset L&R
int Psubdiv;
int Pautopan;
int Preverse;
int Pstages; //filter stages
struct filterstate
{
float sinp;
float cosp; //sinusoid oscillator state variables
float ramp; //frequency oscillator
float level;
float lfo;
float vol;
filterstate():
sinp(),
cosp(),
ramp(),
level(),
lfo(),
vol() {}
} rbandstate[NUM_INF_BANDS], lbandstate[NUM_INF_BANDS];
struct phasevars
{
float yn1[MAX_PHASER_STAGES];
float xn1[MAX_PHASER_STAGES];
float gain;
phasevars():
yn1(),
xn1(),
gain() {}
} rphaser[NUM_INF_BANDS], lphaser[NUM_INF_BANDS];
float phaserfb;
float phaser(phasevars *pstruct, float fxn, int j);
/*
fconst = freq* 2*pi/fs;
rampconst = 2*freq/fs;
*/
float cfconst, fconst; //sine wave oscillator frequency constant // 2*pi*freq/fs
float rampconst, irampconst, crampconst, cirampconst; //ramp oscillator constant// 2*freq/SR
float alpha, beta;
float fstart, fend; //range of filter sweep
float linconst, logconst;
float minlevel, maxlevel;
float frmin, frmax;
float qq;
float stdiff;
float volmaster;
float autopan, msin, dsin, mcos, mconst;
float ratescale;
int tflag;
float* interpbuf; //buffer for filters
class RBFilter *filterl[NUM_INF_BANDS], *filterr[NUM_INF_BANDS];
};
#endif
| 5,708
|
C++
|
.h
| 154
| 31.636364
| 119
| 0.653028
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,541
|
Sequence.h
|
Stazed_rakarrack-plus/src/FX/Sequence.h
|
/*
Rakarrack Guitar FX
Sequence.h - Simple compressor/Sequence effect with easy interface, minimal controls
Copyright (C) 2010 Ryan Billing
Author: Ryan Billing & Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SEQUENCE_H
#define SEQUENCE_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/RBFilter.h"
#include "../EFX_common/smbPitchShift.h"
#include "../EFX_common/beattracker.h"
#include "../EFX_common/delayline.h"
#include "../EFX_common/Resample.h"
#define SEQUENCELV2_URI "https://github.com/Stazed/rakarrack-plus#Sequence"
#define SEQUENCE_NAME "RakarrackPlus Sequence"
const int C_SEQUENCE_PARAMETERS = 15;
enum Sequence_Index
{
Sequence_Step_1,
Sequence_Step_2,
Sequence_Step_3,
Sequence_Step_4,
Sequence_Step_5,
Sequence_Step_6,
Sequence_Step_7,
Sequence_Step_8,
Sequence_DryWet,
Sequence_Tempo,
Sequence_Resonance,
Sequence_Amp,
Sequence_Stdf,
Sequence_Mode,
Sequence_Range
};
static const char *sequence_parameters[] =
{
strdup(NTS(Sequence_Step_1).c_str()), "Step 1", "S1",
strdup(NTS(Sequence_Step_2).c_str()), "Step 2", "S2",
strdup(NTS(Sequence_Step_3).c_str()), "Step 3", "S3",
strdup(NTS(Sequence_Step_4).c_str()), "Step 4", "S4",
strdup(NTS(Sequence_Step_5).c_str()), "Step 5", "S5",
strdup(NTS(Sequence_Step_6).c_str()), "Step 6", "S6",
strdup(NTS(Sequence_Step_7).c_str()), "Step 7", "S7",
strdup(NTS(Sequence_Step_8).c_str()), "Step 8", "S8",
strdup(NTS(Sequence_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Sequence_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(Sequence_Resonance).c_str()), "Q", "Q",
strdup(NTS(Sequence_Amp).c_str()), "Amplitude/Alt. Mode", "AMP",
strdup(NTS(Sequence_Stdf).c_str()), "Right Channel Step Lag", "LAG",
strdup(NTS(Sequence_Mode).c_str()), "Modulation Mode", "MODE",
strdup(NTS(Sequence_Range).c_str()), "Step Adjustment Range", "RANGE"
};
class Sequence : public Effect
{
public:
Sequence (long int Quality, int DS, int uq, int dq, double sample_rate, uint32_t intermediate_bufsze);
~Sequence ();
void cleanup ();
int get_number_efx_parameters () {return C_SEQUENCE_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return SEQUENCELV2_URI; };
virtual std::string get_name(int) {return SEQUENCE_NAME; };
void initialize();
void clear_initialize();
void out (float * efxoutl, float * efxoutr);
void changepar (int npar, int value);
int getpar (int npar);
void setpreset (int npreset);
void setranges(int value);
void settempo(int value);
void adjust(int DS, double sample_rate);
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
private:
void setvolume (int volume);
uint32_t PERIOD;
float fSAMPLE_RATE;
//Parametrii
int DS_state;
long int hq;
int Pvolume; //Output Level
int Psequence[8]; //Sequence. Each value is 0...127
int Ptempo; // Rate
int Pq; //Filter Q
int Pamplitude; // 0 or 1. Checkbox on or off...
int Pstdiff; // 1 2 3 4 5 6 7 8
int Pmode;
int Prange;
unsigned int tcount, scount, dscount, intperiod;
int subdiv;
int rndflag;
unsigned int nPERIOD;
int nSAMPLE_RATE;
float nRATIO;
double u_up;
double u_down;
long window;
float nfSAMPLE_RATE;
float MINFREQ,MAXFREQ;
float fsequence[8];
float fq;
float panning;
float ifperiod,fperiod, seqpower;
float *outi;
float *outo;
float *templ, *tempr;
//Variables for TrigStepper detecting trigger state.
float peakpulse, peak, envrms, peakdecay, trigthresh;
int trigtimeout, trigtime, onset, atk;
float targatk, lmod, rmod;
float maxdly, tempodiv, fb, rdlyfb, ldlyfb;
float avtime;
int avflag;
class RBFilter *filterl, *filterr, *modfilterl, *modfilterr, *rmsfilter, *peaklpfilter, *peakhpfilter, *peaklpfilter2;
float* interpbuf;
Resample *U_Resample;
Resample *D_Resample;
PitchShifter *PS;
class beattracker *beats;
class delayline *ldelay, *rdelay;
};
#endif
| 5,061
|
C++
|
.h
| 139
| 31.992806
| 122
| 0.684653
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,542
|
Gate.h
|
Stazed_rakarrack-plus/src/FX/Gate.h
|
// Based in gate_1410.c LADSPA Swh-plugins
/*
rakarrack - a guitar effects software
Gate.h - Noise Gate Effect definitions
Based on Steve Harris LADSPA gate.
Copyright (C) 2008 Josep Andreu
Author: Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License
(version2) along with this program; if not, write to the Free Software
Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef NOISEGATE_H
#define NOISEGATE_H
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#define GATELV2_URI "https://github.com/Stazed/rakarrack-plus#gate"
#define GATE_NAME "RakarrackPlus NoiseGate"
const int C_GATE_PARAMETERS = 7;
enum Gate_Index
{
Gate_Threshold = 0,
Gate_Range,
Gate_Attack,
Gate_Release,
Gate_LPF,
Gate_HPF,
Gate_Hold
};
static const char *gate_parameters[] =
{
strdup(NTS(Gate_Threshold).c_str()), "Threshold", "THRESHOLD",
strdup(NTS(Gate_Range).c_str()), "Range", "RANGE",
strdup(NTS(Gate_Attack).c_str()), "Attack Time", "ATTACK",
strdup(NTS(Gate_Release).c_str()), "Release Time", "RELEASE",
strdup(NTS(Gate_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(Gate_HPF).c_str()), "Highpass Filter", "HPF",
strdup(NTS(Gate_Hold).c_str()), "Hold", "HOLD"
};
class Gate : public Effect
{
public:
Gate (double sample_rate, uint32_t intermediate_bufsize);
~Gate ();
void out (float *efxoutl, float *efxoutr);
void Dry_Wet_Mix(int NumEffect, float volume,
float *efxoutl, float *efxoutr, float *smpl, float *smpr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_GATE_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return GATELV2_URI; };
virtual std::string get_name(int) {return GATE_NAME; };
void initialize();
void clear_initialize();
private:
// Compressor
int Pthreshold; // attack time (ms)
int Pattack; // release time (ms)
int Ohold;
int Pdecay;
int Prange;
int Plpf;
int Phpf;
int Phold;
void setlpf (int Plpf);
void sethpf (int Phpf);
uint32_t PERIOD;
double fSAMPLE_RATE;
int hold_count;
int state;
float range;
float cut;
float t_level;
float a_rate;
float d_rate;
float env;
float gate;
float fs;
float hold;
float* interpbuf; //buffer for filters
AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr;
};
#endif
| 3,176
|
C++
|
.h
| 97
| 28.701031
| 72
| 0.695595
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,543
|
APhaser.h
|
Stazed_rakarrack-plus/src/FX/APhaser.h
|
/*
ZynAddSubFX - a software synthesizer
APhaser.h - Phaser effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu and Ryan Billing
Further modified for rakarrack by Ryan Billing (Transmogrifox) to model Analog Phaser behavior 2009
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef APHASER_H
#define APHASER_H
#include "Effect.h"
#include "../EFX_common/EffectLFO.h"
#define APHASELV2_URI "https://github.com/Stazed/rakarrack-plus#aphas"
#define APHASE_NAME "RakarrackPlus Analog Phaser"
const int C_APHASER_PARAMETERS = 13;
enum APhaser_Index
{
APhase_DryWet = 0,
APhase_Distortion,
APhase_LFO_Tempo,
APhase_LFO_Random,
APhase_LFO_Type,
APhase_LFO_Stereo,
APhase_Width,
APhase_Feedback,
APhase_Stages,
APhase_Mismatch,
APhase_Subtract,
APhase_Depth,
APhase_Hyper
};
static const char *aphase_parameters[] =
{
strdup(NTS(APhase_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(APhase_Distortion).c_str()), "Distort", "DISTORT",
strdup(NTS(APhase_LFO_Tempo).c_str()), "Tempo", "TEMPO",
strdup(NTS(APhase_LFO_Random).c_str()), "Randomness", "RND",
strdup(NTS(APhase_LFO_Type).c_str()), "LFO Type", "TYPE",
strdup(NTS(APhase_LFO_Stereo).c_str()), "LFO L/R Delay", "STDL",
strdup(NTS(APhase_Width).c_str()), "Width", "WIDTH",
strdup(NTS(APhase_Feedback).c_str()), "Feedback", "FB",
strdup(NTS(APhase_Stages).c_str()), "Stages", "STAGES",
strdup(NTS(APhase_Mismatch).c_str()), "Mismatch", "MISMATCH",
strdup(NTS(APhase_Subtract).c_str()), "Subtract", "SUB",
strdup(NTS(APhase_Depth).c_str()), "Phase Depth", "DEPTH",
strdup(NTS(APhase_Hyper).c_str()), "Hyper", "HYPER"
};
class Analog_Phaser : public Effect
{
public:
Analog_Phaser (double sample_rate, uint32_t intermediate_bufsize);
~Analog_Phaser ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_APHASER_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return APHASELV2_URI; };
virtual std::string get_name(int) {return APHASE_NAME; };
private:
float fPERIOD;
protected:
uint32_t PERIOD;
private:
//Phaser parameters
int Pvolume; //Used in Process.C to set wet/dry mix
int Pdistortion; //Model distortion added by FET element
int Pwidth; //Phaser width (LFO amplitude)
int Pfb; //feedback
int Poffset; //Model mismatch between variable resistors
int Pstages; //Number of first-order All-Pass stages
protected:
int Poutsub; //if I wish to subtract the output instead of the adding it
int Phyper; //lfo^2 -- converts tri into hyper-sine
private:
int Pdepth; //Depth of phaser sweep
int Pbarber; //Enable barber pole phasing
protected:
//Control parameters
void setvolume (int _Pvolume);
void setdistortion (int _Pdistortion);
void setwidth (int _Pwidth);
void setfb (int _Pfb);
void setoffset (int _Poffset);
void setstages (int _Pstages);
void setdepth (int _Pdepth);
//Internal Variables
bool barber; //Barber pole phasing flag
private:
float distortion, fb, width, offsetpct, fbl, fbr, depth;
float *lxn1, *lyn1,*rxn1, *ryn1, *offset;
float oldlgain, oldrgain, rdiff, ldiff, invperiod;
float mis;
float Rmin; // 2N5457 typical on resistance at Vgs = 0
float Rmax; // Resistor parallel to FET
float Rmx; // Rmin/Rmax to avoid division in loop
float Rconst; // Handle parallel resistor relationship
float C; // Capacitor
float CFs; // A constant derived from capacitor and resistor relationships
protected:
EffectLFO *lfo; //Phaser modulator
};
#endif
| 4,712
|
C++
|
.h
| 119
| 35.537815
| 101
| 0.70127
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,544
|
Shuffle.h
|
Stazed_rakarrack-plus/src/FX/Shuffle.h
|
/*
Shuffle.h - Stereo Shuffle
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
ZynAddSubFX - a software synthesizer
Modified for rakarrack by Josep Andreu & Hernan Ordiales
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SHUFFLE_H
#define SHUFFLE_H
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#define SHUFFLELV2_URI "https://github.com/Stazed/rakarrack-plus#Shuffle"
#define SHUFFLE_NAME "RakarrackPlus Shuffle"
const int C_SHUFFLE_PARAMETERS = 11;
enum Shuffle_Index
{
Shuffle_DryWet = 0,
Shuffle_Gain_L,
Shuffle_Gain_ML,
Shuffle_Gain_MH,
Shuffle_Gain_H,
Shuffle_Freq_L,
Shuffle_Freq_ML,
Shuffle_Freq_MH,
Shuffle_Freq_H,
Shuffle_Width,
Shuffle_F_Band
};
static const char *shuffle_parameters[] =
{
strdup(NTS(Shuffle_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Shuffle_Gain_L).c_str()), "Low Gain", "LGAIN",
strdup(NTS(Shuffle_Gain_ML).c_str()), "Mid Low Gain", "M1GAIN",
strdup(NTS(Shuffle_Gain_MH).c_str()), "Mid High Gain", "M2GAIN",
strdup(NTS(Shuffle_Gain_H).c_str()), "High Gain", "HGAIN",
strdup(NTS(Shuffle_Freq_L).c_str()), "Low Frequency", "LFREQ",
strdup(NTS(Shuffle_Freq_ML).c_str()), "Mid Low Frequency", "M1FREQ",
strdup(NTS(Shuffle_Freq_MH).c_str()), "Mid High Frequency", "M2FREQ",
strdup(NTS(Shuffle_Freq_H).c_str()), "High Frequency", "HFREQ",
strdup(NTS(Shuffle_Width).c_str()), "Width", "Q",
strdup(NTS(Shuffle_F_Band).c_str()), "Filtered Band", "BAND"
};
class Shuffle : public Effect
{
public:
Shuffle (double sample_rate, uint32_t intermediate_bufsize);
~Shuffle ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_SHUFFLE_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return SHUFFLELV2_URI; };
virtual std::string get_name(int) {return SHUFFLE_NAME; };
void initialize();
void clear_initialize();
private:
float *inputl;
float *inputr;
void setvolume (int Pvolume);
void setCross1 (int value);
void setCross2 (int value);
void setCross3 (int value);
void setCross4 (int value);
void setGainL (int value);
void setGainML (int value);
void setGainMH (int value);
void setGainH (int value);
void set_q(int value);
uint32_t PERIOD;
double fSAMPLE_RATE;
//Parametrii
int Pvolume; //Volumul or E/R
int PvolL;
int PvolML;
int PvolMH;
int PvolH;
int PQ;
int E;
int Cross1; //lowpass filter
int Cross2; //highpass filter
int Cross3;
int Cross4;
//Parametrii reali
float tmp;
float volL,volML,volMH,volH;
AnalogFilter *lr, *hr;
AnalogFilter *mlr,*mhr;
float* interpbuf; //buffer for filters
};
#endif
| 3,746
|
C++
|
.h
| 107
| 30.691589
| 79
| 0.693974
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,545
|
Reverb.h
|
Stazed_rakarrack-plus/src/FX/Reverb.h
|
/*
ZynAddSubFX - a software synthesizer
Reverb.h - Reverberation effect
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
Modified for rakarrack by Josep Andreu
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef REVERB_H
#define REVERB_H
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#define REVELV2_URI "https://github.com/Stazed/rakarrack-plus#reve"
#define REVE_NAME "RakarrackPlus Reverb"
const int C_REVERB_PARAMETERS = 12;
enum Reverb_Index
{
Reverb_DryWet = 0,
Reverb_Pan,
Reverb_Time,
Reverb_I_Delay,
Reverb_Delay_FB,
Reverb_SKIP_5,
Reverb_SKIP_6,
Reverb_LPF,
Reverb_HPF,
Reverb_Damp,
Reverb_Type,
Reverb_Room
};
static const char *reverb_parameters[] =
{
strdup(NTS(Reverb_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Reverb_Pan).c_str()), "Panning", "PAN",
strdup(NTS(Reverb_Time).c_str()), "Time", "TIME",
strdup(NTS(Reverb_I_Delay).c_str()), "Initial Delay", "IDEL",
strdup(NTS(Reverb_Delay_FB).c_str()), "Initial Delay Feedback", "IDELFB",
strdup(NTS(Reverb_LPF).c_str()), "Lowpass Filter", "LPF",
strdup(NTS(Reverb_HPF).c_str()), "Highpass Filter", "HPF",
strdup(NTS(Reverb_Damp).c_str()), "Damping", "DAMP",
strdup(NTS(Reverb_Type).c_str()), "Type", "TYPE",
strdup(NTS(Reverb_Room).c_str()), "Room Size", "RS"
};
class Reverb : public Effect
{
public:
Reverb (double samplerate, uint16_t intermediate_bufsize);
~Reverb ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_REVERB_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return REVELV2_URI; };
virtual std::string get_name(int) {return REVE_NAME; };
void initialize();
void clear_initialize();
private:
void setvolume (int _Pvolume);
void setpan (int _Ppan);
void settime (int _Ptime);
void setlohidamp (int _Plohidamp);
void setidelay (int _Pidelay);
void setidelayfb (int _Pidelayfb);
void sethpf (int value);
void setlpf (int value);
void settype (int _Ptype);
void setroomsize (int _Proomsize);
void processmono (unsigned int ch, float * output);
float fSAMPLE_RATE;
uint32_t PERIOD;
//Parametrii
//Amount of the reverb,
int Pvolume;
//LefT/Right Panning
int Ppan;
//duration of reverb
int Ptime;
//Initial delay
int Pidelay;
//Initial delay feedback
int Pidelayfb;
//delay between ER/Reverbs
int Prdelay;
//EarlyReflections/Reverb Balance
int Perbalance;
//HighPassFilter
int Plpf;
//LowPassFilter
int Phpf;
//Low/HighFrequency Damping
int Plohidamp; // 0..63 lpf,64=off,65..127=hpf(TODO)
//Reverb type
int Ptype;
//Room Size
int Proomsize;
//Parametrii 2
int lohidamptype; //0=disable,1=highdamp(lowpass),2=lowdamp(highpass))
int idelaylen, rdelaylen;
int idelayk;
int comblen[REV_COMBS * 2];
int aplen[REV_APS * 2];
int combk[REV_COMBS * 2];
int apk[REV_APS * 2];
float lohifb, idelayfb, roomsize, rs; //rs is used to "normalise" the volume according to the roomsize
float rs_coeff;
//parameter control
float pan, erbalance;
//Valorile interne
float *comb[REV_COMBS * 2];
float combfb[REV_COMBS * 2]; //feedback-ul fiecarui filtru "comb"
float lpcomb[REV_COMBS * 2]; //pentru Filtrul LowPass
float *ap[REV_APS * 2];
float *inputbuf;
float *idelay;
float* interpbuf; //buffer for filters
class AnalogFilter *lpf, *hpf; //filters
};
#endif
| 4,549
|
C++
|
.h
| 134
| 29.425373
| 106
| 0.688344
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,546
|
Vocoder.h
|
Stazed_rakarrack-plus/src/FX/Vocoder.h
|
/*
Vocoder.h - Vocoder Effect
Author: Ryam Billing & Josep Andreu
Adapted effect structure of ZynAddSubFX - a software synthesizer
Author: Nasca Octavian Paul
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef VOCODER_H
#define VOCODER_H
#include <vector>
#include "Effect.h"
#include "../EFX_common/AnalogFilter.h"
#include "../EFX_common/Resample.h"
#define VOCODERLV2_URI "https://github.com/Stazed/rakarrack-plus#Vocoder"
#define VOCODER_NAME "RakarrackPlus Vocoder"
const int C_VOCODER_PARAMETERS = 7;
enum Vocoder_Index
{
Vocoder_DryWet = 0,
Vocoder_Pan,
Vocoder_Smear,
Vocoder_Q,
Vocoder_Input,
Vocoder_Level,
Vocoder_Ring
};
static const char *vocoder_parameters[] =
{
strdup(NTS(Vocoder_DryWet).c_str()), "Dry/Wet", "DRYWET",
strdup(NTS(Vocoder_Pan).c_str()), "Pan", "PAN",
strdup(NTS(Vocoder_Smear).c_str()), "Smear", "MUF",
strdup(NTS(Vocoder_Q).c_str()), "Q", "Q",
strdup(NTS(Vocoder_Input).c_str()), "Input Gain", "INGAIN",
strdup(NTS(Vocoder_Level).c_str()), "Level", "LEVEL",
strdup(NTS(Vocoder_Ring).c_str()), "Ring Mod. Depth", "RING"
};
class Vocoder : public Effect
{
public:
Vocoder (float *auxresampled_,int bands, int DS, int uq, int dq, double sample_rate, uint32_t intermediate_bufsize);
~Vocoder ();
void out (float * efxoutl, float * efxoutr);
void setpreset (int npreset);
void changepar (int npar, int value);
int getpar (int npar);
void cleanup ();
int get_number_efx_parameters () {return C_VOCODER_PARAMETERS;};
void set_random_parameters();
#ifdef LV2_SUPPORT
void lv2_update_params(uint32_t period);
#endif // LV2
virtual void LV2_parameters(std::string &s_buf, int type);
virtual std::string get_URI(int) { return VOCODERLV2_URI; };
virtual std::string get_name(int) {return VOCODER_NAME; };
void initialize();
void clear_initialize();
void adjust(int DS, double sample_rate);
/* Change quality */
std::vector<int> save_parameters();
void reset_parameters(std::vector<int> parameters);
float vulevel;
float *auxresampled;
private:
void setvolume (int _Pvolume);
void setpanning (int _Ppanning);
void init_filters();
void adjustq(int value);
void setbands(int numbands, float startfreq, float endfreq);
int VOC_BANDS;
uint32_t PERIOD;
double fSAMPLE_RATE;
int DS_state;
//Parametrii
int Pvolume; //This is master wet/dry mix like other FX...but I am finding it is not useful
int Ppanning; //Panning
int Plrcross; // L/R Mixing // This is a mono effect, so lrcross and panning are pointless
int Plevel; //This should only adjust the level of the IR effect, and not wet/dry mix
int Pinput;
int Pband;
int Pmuffle;
int Pqq;
int Pring;
int nPERIOD;
int nSAMPLE_RATE;
float nRATIO;
float ncSAMPLE_RATE;
float nfSAMPLE_RATE;
double u_up;
double u_down;
float ringworm;
float lpanning, rpanning, input,level;
float alpha,beta,prls,gate;
float compeak, compg, compenv, oldcompenv, calpha, cbeta, cthresh, cratio, cpthresh;
float *tmpl, *tmpr;
float *tsmpsl, *tsmpsr;
float *tmpaux;
struct fbank
{
float sfreq, sq,speak,gain,oldgain;
AnalogFilter *l, *r, *aux;
fbank():
sfreq(),
sq(),
speak(),
gain(),
oldgain(),
l(),
r(),
aux() {}
} *filterbank;
AnalogFilter *vhp, *vlp;
float* interpbuf; //buffer for filters
Resample *U_Resample;
Resample *D_Resample;
Resample *A_Resample;
};
#endif
| 4,331
|
C++
|
.h
| 126
| 29.31746
| 120
| 0.679509
|
Stazed/rakarrack-plus
| 36
| 8
| 10
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,547
|
admc_test_select_base_widget.cpp
|
altlinux_admc/tests/admc_test_select_base_widget.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_select_base_widget.h"
#include "console_impls/object_impl.h"
#include "filter_widget/select_base_widget.h"
#include "filter_widget/ui_select_base_widget.h"
#include "globals.h"
#include "select_dialogs/select_container_dialog.h"
#include <QComboBox>
#include <QPushButton>
#include <QTreeView>
#include <QVBoxLayout>
void ADMCTestSelectBaseWidget::init() {
ADMCTest::init();
select_base_widget = new SelectBaseWidget();
add_widget(select_base_widget);
combo = select_base_widget->ui->combo;
// Create test OU's
const QList<QString> ou_name_list = {
"test-ou-alpha",
"test-ou-beta",
"test-ou-gamma",
};
dn_list.clear();
for (const QString &ou_name : ou_name_list) {
const QString dn = test_object_dn(ou_name, CLASS_OU);
dn_list.append(dn);
const bool create_success = ad.object_add(dn, CLASS_OU);
QVERIFY(create_success);
}
}
// By default, domain head should be selected
void ADMCTestSelectBaseWidget::default_to_domain_dn() {
const QString domain_dn = g_adconfig->domain_dn();
const QString base = select_base_widget->get_base();
QCOMPARE(base, domain_dn);
}
// After selecting a search base, the widget should return
// the DN of selected search base
void ADMCTestSelectBaseWidget::select_base() {
const QString select_dn = dn_list[0];
select_base_widget_add(select_base_widget, select_dn);
const QString base = select_base_widget->get_base();
QCOMPARE(base, select_dn);
}
// Adding a base more than once should not create duplicates
void ADMCTestSelectBaseWidget::no_duplicates() {
QCOMPARE(combo->count(), 1);
const QString alpha = dn_list[0];
const QString beta = dn_list[1];
select_base_widget_add(select_base_widget, alpha);
QCOMPARE(combo->count(), 2);
select_base_widget_add(select_base_widget, beta);
QCOMPARE(combo->count(), 3);
select_base_widget_add(select_base_widget, alpha);
QCOMPARE(combo->count(), 3);
}
// Adding a base that has already been added while
// another base is selected should change selection to
// that base.
void ADMCTestSelectBaseWidget::select_base_of_already_added() {
const QString alpha = dn_list[0];
const QString beta = dn_list[1];
select_base_widget_add(select_base_widget, alpha);
QCOMPARE(select_base_widget->get_base(), alpha);
select_base_widget_add(select_base_widget, beta);
QCOMPARE(select_base_widget->get_base(), beta);
select_base_widget_add(select_base_widget, alpha);
QCOMPARE(select_base_widget->get_base(), alpha);
}
// Adding multiple search bases to combo box, then selecting
// one of them in the combobox should make the widget return
// that search base.
void ADMCTestSelectBaseWidget::select_base_multiple() {
for (const QString &dn : dn_list) {
select_base_widget_add(select_base_widget, dn);
}
// Alpha is at index 1 in the combo (0 is domain)
combo->setCurrentIndex(1);
const QString base = select_base_widget->get_base();
QCOMPARE(base, dn_list[0]);
}
void ADMCTestSelectBaseWidget::save_state() {
// Setup some state
for (const QString &dn : dn_list) {
select_base_widget_add(select_base_widget, dn);
}
combo->setCurrentIndex(1);
const QString base_original = select_base_widget->get_base();
// Serialize
const QVariant state = select_base_widget->save_state();
// Change state
combo->setCurrentIndex(2);
// Deserialize
select_base_widget->restore_state(state);
// Check that deserialization successfully restored
// original state
const QString base_deserialized = select_base_widget->get_base();
QCOMPARE(base_original, base_deserialized);
}
QTEST_MAIN(ADMCTestSelectBaseWidget)
| 4,565
|
C++
|
.cpp
| 118
| 34.79661
| 72
| 0.716259
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,548
|
admc_test_create_object_dialog.cpp
|
altlinux_admc/tests/admc_test_create_object_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_create_object_dialog.h"
#include "adldap.h"
#include "create_dialogs/create_computer_dialog.h"
#include "create_dialogs/create_contact_dialog.h"
#include "create_dialogs/create_group_dialog.h"
#include "create_dialogs/create_ou_dialog.h"
#include "create_dialogs/create_shared_folder_dialog.h"
#include "create_dialogs/create_user_dialog.h"
#include "samba/dom_sid.h"
#include "settings.h"
#include "ui_create_computer_dialog.h"
#include "ui_create_contact_dialog.h"
#include "ui_create_group_dialog.h"
#include "ui_create_ou_dialog.h"
#include "ui_create_shared_folder_dialog.h"
#include "ui_create_user_dialog.h"
void test_lineedit_autofill(QLineEdit *src_edit, QLineEdit *dest_edit);
void test_full_name_autofill(QLineEdit *first_name_edit, QLineEdit *last_name_edit, QLineEdit *full_name_edit);
void ADMCTestCreateObjectDialog::create_user_data() {
QTest::addColumn<QString>("user_class");
QTest::addColumn<QString>("password");
QTest::addColumn<bool>("expected_object_exists");
QTest::addColumn<bool>("expected_message_box_is_open");
QTest::newRow("user") << CLASS_USER << TEST_PASSWORD << true << false;
QTest::newRow("inetOrgPerson") << CLASS_INET_ORG_PERSON << TEST_PASSWORD << true << false;
QTest::newRow("user empty password") << CLASS_USER << QString() << false << true;
}
void ADMCTestCreateObjectDialog::create_user() {
QFETCH(QString, user_class);
QFETCH(QString, password);
QFETCH(bool, expected_object_exists);
QFETCH(bool, expected_message_box_is_open);
const QString name = TEST_USER;
const QString logon_name = TEST_USER_LOGON;
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, CLASS_USER);
// Create user
auto create_dialog = new CreateUserDialog(ad, parent, user_class, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->name_edit->setText(name);
create_dialog->ui->sam_name_edit->setText(logon_name);
create_dialog->ui->password_main_edit->setText(password);
create_dialog->ui->password_confirm_edit->setText(password);
create_dialog->accept();
const bool actual_message_box_is_open = message_box_is_open();
QCOMPARE(actual_message_box_is_open, expected_message_box_is_open);
const bool actual_object_exists = object_exists(dn);
QCOMPARE(actual_object_exists, expected_object_exists);
if (actual_object_exists) {
QCOMPARE(create_dialog->get_created_dn(), dn);
const int actual_uac = [&]() {
const AdObject object = ad.search_object(dn, {ATTRIBUTE_USER_ACCOUNT_CONTROL});
const int out = object.get_int(ATTRIBUTE_USER_ACCOUNT_CONTROL);
return out;
}();
const int expected_uac = UAC_NORMAL_ACCOUNT;
QCOMPARE(actual_uac, expected_uac);
}
}
void ADMCTestCreateObjectDialog::create_user_autofill() {
const QString object_class = CLASS_USER;
const QString name = TEST_OBJECT;
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, object_class);
auto create_dialog = new CreateUserDialog(ad, parent, object_class, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
test_lineedit_autofill(create_dialog->ui->upn_prefix_edit, create_dialog->ui->sam_name_edit);
test_full_name_autofill(create_dialog->ui->first_name_edit, create_dialog->ui->last_name_edit, create_dialog->ui->name_edit);
}
void ADMCTestCreateObjectDialog::create_ou() {
const QString name = TEST_OU;
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, CLASS_OU);
// Create ou
auto create_dialog = new CreateOUDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->name_edit->setText(name);
create_dialog->accept();
QVERIFY2(object_exists(dn), "Created OU doesn't exist");
QCOMPARE(create_dialog->get_created_dn(), dn);
}
void ADMCTestCreateObjectDialog::create_computer() {
const QString object_class = CLASS_COMPUTER;
const QString name = TEST_COMPUTER;
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, object_class);
// Open create dialog
auto create_dialog = new CreateComputerDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->name_edit->setText(name);
create_dialog->ui->sam_name_edit->setText(name);
create_dialog->accept();
const QString actual_dn = create_dialog->get_created_dn();
QVERIFY2(object_exists(dn), "Created computer doesn't exist");
QCOMPARE(actual_dn, dn);
const AdObject object = ad.search_object(actual_dn);
const int actual_sam_type = object.get_int(ATTRIBUTE_SAM_ACCOUNT_TYPE);
const int expected_sam_type = SAM_MACHINE_ACCOUNT;
QCOMPARE(actual_sam_type, expected_sam_type);
const int actual_primary_group_rid = object.get_int(ATTRIBUTE_PRIMARY_GROUP_ID);
const int expected_primary_group_rid = DOMAIN_RID_DOMAIN_MEMBERS;
QCOMPARE(actual_primary_group_rid, expected_primary_group_rid);
const int actual_uac = object.get_int(ATTRIBUTE_USER_ACCOUNT_CONTROL);
const int expected_uac = (UAC_PASSWD_NOTREQD | UAC_WORKSTATION_TRUST_ACCOUNT);
QCOMPARE(actual_uac, expected_uac);
const QString actual_sam_name = object.get_string(ATTRIBUTE_SAM_ACCOUNT_NAME);
const QString expected_sam_name = QString("%1$").arg(name);
QCOMPARE(actual_sam_name, expected_sam_name);
}
void ADMCTestCreateObjectDialog::create_computer_autofill() {
const QString object_class = CLASS_COMPUTER;
const QString name = TEST_COMPUTER;
const QString parent = test_arena_dn();
auto create_dialog = new CreateComputerDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->name_edit->setText(name);
const QString actual_sam_name = create_dialog->ui->sam_name_edit->text();
const QString expected_sam_name = name.toUpper();
QCOMPARE(actual_sam_name, expected_sam_name);
}
void ADMCTestCreateObjectDialog::create_group() {
const QString object_class = CLASS_GROUP;
const QString name = TEST_GROUP;
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, object_class);
// Open create dialog
auto create_dialog = new CreateGroupDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->name_edit->setText(name);
create_dialog->ui->sam_name_edit->setText(name);
create_dialog->accept();
QVERIFY2(object_exists(dn), "Created group doesn't exist");
QCOMPARE(create_dialog->get_created_dn(), dn);
}
void ADMCTestCreateObjectDialog::create_group_autofill() {
// NOTE: use shorter name because of sam name limits
const QString name = TEST_OBJECT;
const QString parent = test_arena_dn();
auto create_dialog = new CreateGroupDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->name_edit->setText(name);
const QString actual_sam_name = create_dialog->ui->sam_name_edit->text();
const QString expected_sam_name = name;
QCOMPARE(actual_sam_name, expected_sam_name);
}
void ADMCTestCreateObjectDialog::create_shared_folder() {
const QString object_class = CLASS_SHARED_FOLDER;
const QString name = TEST_OBJECT;
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, object_class);
// Open create dialog
auto create_dialog = new CreateSharedFolderDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->name_edit->setText(name);
create_dialog->ui->path_edit->setText("path");
create_dialog->accept();
QVERIFY2(object_exists(dn), "Created shared folder doesn't exist");
QCOMPARE(create_dialog->get_created_dn(), dn);
}
void ADMCTestCreateObjectDialog::create_contact() {
const QString object_class = CLASS_CONTACT;
const QString name = TEST_OBJECT;
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, object_class);
// Open create dialog
auto create_dialog = new CreateContactDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->first_name_edit->setText("first");
create_dialog->ui->last_name_edit->setText("last");
create_dialog->ui->full_name_edit->setText(name);
create_dialog->ui->display_name_edit->setText("display");
create_dialog->accept();
QVERIFY2(object_exists(dn), "Created contact doesn't exist");
QCOMPARE(create_dialog->get_created_dn(), dn);
}
void ADMCTestCreateObjectDialog::create_contact_autofill() {
const QString object_class = CLASS_CONTACT;
const QString name = TEST_OBJECT;
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, object_class);
auto create_dialog = new CreateContactDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
test_full_name_autofill(create_dialog->ui->first_name_edit, create_dialog->ui->last_name_edit, create_dialog->ui->full_name_edit);
}
void ADMCTestCreateObjectDialog::trim() {
const QString name = TEST_OU;
const QString name_untrimmed = QString(" %1 ").arg(name);
const QString parent = test_arena_dn();
const QString dn = test_object_dn(name, CLASS_OU);
auto create_dialog = new CreateOUDialog(parent, parent_widget);
create_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(create_dialog, 1000));
create_dialog->ui->name_edit->setText(name_untrimmed);
create_dialog->accept();
QVERIFY(object_exists(dn));
QCOMPARE(create_dialog->get_created_dn(), dn);
}
void test_full_name_autofill(QLineEdit *first_name_edit, QLineEdit *last_name_edit, QLineEdit *full_name_edit) {
const QString first_name = "first";
const QString last_name = "last";
first_name_edit->setText(first_name);
last_name_edit->setText(last_name);
const QString actual_full_name = full_name_edit->text();
const QString expected_full_name = [&]() {
const bool last_name_first = settings_get_variant(SETTING_last_name_before_first_name).toBool();
if (last_name_first) {
return QString("%1 %2").arg(last_name, first_name);
} else {
return QString("%1 %2").arg(first_name, last_name);
}
}();
QCOMPARE(actual_full_name, expected_full_name);
}
QTEST_MAIN(ADMCTestCreateObjectDialog)
| 11,756
|
C++
|
.cpp
| 243
| 43.753086
| 134
| 0.72129
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,549
|
admc_test_bool_attribute_dialog.cpp
|
altlinux_admc/tests/admc_test_bool_attribute_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_bool_attribute_dialog.h"
#include "attribute_dialogs/bool_attribute_dialog.h"
#include "attribute_dialogs/ui_bool_attribute_dialog.h"
#include <QRadioButton>
void ADMCTestBoolAttributeDialog::initTestCase_data() {
QTest::addColumn<QString>("button_name");
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::newRow("true") << "true_button" << QList<QByteArray>({"TRUE"});
QTest::newRow("false") << "false_button" << QList<QByteArray>({"FALSE"});
QTest::newRow("unset") << "unset_button" << QList<QByteArray>();
}
void ADMCTestBoolAttributeDialog::init() {
ADMCTest::init();
QFETCH_GLOBAL(QList<QByteArray>, value_list);
dialog = new BoolAttributeDialog(value_list, ATTRIBUTE_DESCRIPTION, false, parent_widget);
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
}
void ADMCTestBoolAttributeDialog::display_value() {
const QHash<QString, QRadioButton *> button_map = {
{"true_button", dialog->ui->true_button},
{"false_button", dialog->ui->false_button},
{"unset_button", dialog->ui->unset_button},
};
QFETCH_GLOBAL(QString, button_name);
button = button_map[button_name];
QVERIFY(button->isChecked());
}
void ADMCTestBoolAttributeDialog::get_value_list() {
QFETCH_GLOBAL(QList<QByteArray>, value_list);
const QList<QByteArray> actual_value_list = dialog->get_value_list();
QCOMPARE(actual_value_list, value_list);
}
QTEST_MAIN(ADMCTestBoolAttributeDialog)
| 2,285
|
C++
|
.cpp
| 53
| 39.679245
| 94
| 0.728462
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,550
|
admc_test_number_attribute_dialog.cpp
|
altlinux_admc/tests/admc_test_number_attribute_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_number_attribute_dialog.h"
#include "attribute_dialogs/number_attribute_dialog.h"
#include "attribute_dialogs/ui_number_attribute_dialog.h"
#include <QLineEdit>
void ADMCTestNumberAttributeDialog::init_edit(const QList<QByteArray> &value_list) {
dialog = new NumberAttributeDialog(value_list, ATTRIBUTE_NAME, false, parent_widget);
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
line_edit = dialog->ui->edit;
}
void ADMCTestNumberAttributeDialog::display_value_data() {
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::addColumn<QString>("display_value");
QTest::newRow("empty") << QList<QByteArray>() << "";
QTest::newRow("non-empty") << QList<QByteArray>({"123"}) << "123";
}
void ADMCTestNumberAttributeDialog::display_value() {
QFETCH(QList<QByteArray>, value_list);
QFETCH(QString, display_value);
init_edit(value_list);
const QString actual_display_value = line_edit->text();
QCOMPARE(actual_display_value, display_value);
}
void ADMCTestNumberAttributeDialog::get_value_list_data() {
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::newRow("empty") << QList<QByteArray>();
QTest::newRow("non-empty") << QList<QByteArray>({"123"});
}
void ADMCTestNumberAttributeDialog::get_value_list() {
QFETCH(QList<QByteArray>, value_list);
init_edit(value_list);
const QList<QByteArray> value_list_from_dialog = dialog->get_value_list();
QCOMPARE(value_list_from_dialog, value_list);
}
void ADMCTestNumberAttributeDialog::validate_data() {
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::addColumn<Qt::Key>("pressed_key");
QTest::addColumn<QList<QByteArray>>("expected_value_list");
QTest::addColumn<QString>("expected_display_value");
QTest::newRow("press '1'") << QList<QByteArray>({"123"}) << Qt::Key_1 << QList<QByteArray>({"1231"}) << "1231";
QTest::newRow("press 'a'") << QList<QByteArray>({"123"}) << Qt::Key_A << QList<QByteArray>({"123"}) << "123";
}
void ADMCTestNumberAttributeDialog::validate() {
QFETCH(QList<QByteArray>, value_list);
QFETCH(Qt::Key, pressed_key);
QFETCH(QList<QByteArray>, expected_value_list);
QFETCH(QString, expected_display_value);
init_edit(value_list);
QTest::keyPress(line_edit, pressed_key);
QTest::keyPress(line_edit, Qt::Key_Enter);
const QList<QByteArray> actual_value_list = dialog->get_value_list();
QCOMPARE(actual_value_list, expected_value_list);
const QString actual_display_value = line_edit->text();
QCOMPARE(actual_display_value, expected_display_value);
}
QTEST_MAIN(ADMCTestNumberAttributeDialog)
| 3,459
|
C++
|
.cpp
| 75
| 42.6
| 115
| 0.725974
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,551
|
admc_test_unlock_edit.cpp
|
altlinux_admc/tests/admc_test_unlock_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_unlock_edit.h"
#include "attribute_edits/unlock_edit.h"
#include <QCheckBox>
#include <QFormLayout>
// NOTE: this doesn't really "lock" accounts. Accounts can
// only be locked by the server and lockout time only
// displays the state. Since unlock edit modifies lockout
// time, test it like this.
#define LOCKOUT_LOCKED_VALUE "1"
void ADMCTestUnlockEdit::init() {
ADMCTest::init();
checkbox = new QCheckBox(parent_widget);
unlock_edit = new UnlockEdit(checkbox, parent_widget);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
// edited() signal should be emitted when checkbox is toggled
void ADMCTestUnlockEdit::test_emit_edited_signal() {
bool edited_signal_emitted = false;
connect(
unlock_edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
// Check checkbox
checkbox->setChecked(true);
QVERIFY(edited_signal_emitted);
// Unheck checkbox
edited_signal_emitted = false;
checkbox->setChecked(false);
QVERIFY(edited_signal_emitted);
}
// Edit should start out as unchecked after loading user
void ADMCTestUnlockEdit::unchecked_after_load() {
load_locked_user_into_edit();
const bool apply_success = unlock_edit->apply(ad, dn);
QVERIFY(apply_success);
const bool checkbox_is_unchecked = (!checkbox->isChecked());
QVERIFY2(checkbox_is_unchecked, "Checkbox wasn't unchecked after load() call");
}
void ADMCTestUnlockEdit::apply_unmodified() {
test_edit_apply_unmodified(unlock_edit, dn);
}
// Edit should do nothing if checkbox is unchecked (locked
// user stays locked)
void ADMCTestUnlockEdit::test_apply_unchecked() {
load_locked_user_into_edit();
checkbox->setChecked(false);
const bool apply_success = unlock_edit->apply(ad, dn);
QVERIFY(apply_success);
QVERIFY2(!user_is_unlocked(), "Edit unlocked user when the checkbox was unchecked. Edit should've done nothing.");
}
// Edit should unlock locked user if checkbox is checked
void ADMCTestUnlockEdit::test_apply_checked() {
load_locked_user_into_edit();
checkbox->setChecked(true);
const bool apply_success = unlock_edit->apply(ad, dn);
QVERIFY(apply_success);
QVERIFY2(user_is_unlocked(), "Edit failed to unlock user.");
}
// Edit should uncheck the checkbox after applying
void ADMCTestUnlockEdit::uncheck_after_apply() {
checkbox->setChecked(true);
const bool apply_success = unlock_edit->apply(ad, dn);
QVERIFY(apply_success);
const bool checkbox_is_unchecked = (!checkbox->isChecked());
QVERIFY2(checkbox_is_unchecked, "Checkbox wasn't unchecked after apply() call");
}
bool ADMCTestUnlockEdit::user_is_unlocked() {
const AdObject object = ad.search_object(dn);
const QString lockout_time = object.get_string(ATTRIBUTE_LOCKOUT_TIME);
const bool is_unlocked = (lockout_time == LOCKOUT_UNLOCKED_VALUE);
return is_unlocked;
}
void ADMCTestUnlockEdit::load_locked_user_into_edit() {
// Lock test user
ad.attribute_replace_string(dn, ATTRIBUTE_LOCKOUT_TIME, LOCKOUT_LOCKED_VALUE);
// Load user into edit
const AdObject object = ad.search_object(dn);
unlock_edit->load(ad, object);
}
QTEST_MAIN(ADMCTestUnlockEdit)
| 4,202
|
C++
|
.cpp
| 105
| 36.361905
| 118
| 0.731563
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,552
|
admc_test_members_tab.cpp
|
altlinux_admc/tests/admc_test_members_tab.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_members_tab.h"
#include "select_dialogs/select_object_dialog.h"
#include "tabs/membership_tab.h"
#include "tabs/ui_membership_tab.h"
#include <QPushButton>
#include <QStandardItemModel>
#include <QTreeView>
#include <QVBoxLayout>
void ADMCTestMembersTab::init() {
ADMCTest::init();
view = new QTreeView(parent_widget);
auto primary_button = new QPushButton(parent_widget);
add_button = new QPushButton(parent_widget);
remove_button = new QPushButton(parent_widget);
auto properties_button = new QPushButton(parent_widget);
auto primary_group_label = new QLabel(parent_widget);
edit = new MembershipTabEdit(view, primary_button, add_button, remove_button, properties_button, primary_group_label, MembershipTabType_Members, parent_widget);
model = edit->findChild<QStandardItemModel *>();
QVERIFY(model);
// Create test user
const QString user_name = TEST_USER;
user_dn = test_object_dn(user_name, CLASS_USER);
const bool create_user_success = ad.object_add(user_dn, CLASS_USER);
QVERIFY(create_user_success);
// Create test group
const QString group_name = TEST_GROUP;
group_dn = test_object_dn(group_name, CLASS_GROUP);
const bool create_group_success = ad.object_add(group_dn, CLASS_GROUP);
QVERIFY(create_group_success);
// Load it into the tab
const AdObject object = ad.search_object(group_dn);
edit->load(ad, object);
}
// Loading a group without members should result in empty
// model
void ADMCTestMembersTab::load_empty() {
QCOMPARE(model->rowCount(), 0);
}
// Loading a group with members should put members in the
// model
void ADMCTestMembersTab::load() {
const bool add_success = ad.group_add_member(group_dn, user_dn);
QVERIFY(add_success);
const AdObject object = ad.search_object(group_dn);
edit->load(ad, object);
QCOMPARE(model->rowCount(), 1);
auto item = model->item(0, 0);
QCOMPARE(item->text(), dn_get_name(user_dn));
}
// Removing members should remove members from model and group
void ADMCTestMembersTab::remove() {
load();
const QModelIndex index = model->index(0, 0);
view->setCurrentIndex(index);
remove_button->click();
edit->apply(ad, group_dn);
const AdObject updated_object = ad.search_object(group_dn);
const QList<QString> member_list = updated_object.get_strings(ATTRIBUTE_MEMBER);
QCOMPARE(model->rowCount(), 0);
QVERIFY(member_list.isEmpty());
}
void ADMCTestMembersTab::add() {
add_button->click();
select_object_dialog_select(user_dn);
// Check ui state before applying
QCOMPARE(model->rowCount(), 1);
QCOMPARE(model->item(0, 0)->text(), dn_get_name(user_dn));
// Apply and check object state
edit->apply(ad, group_dn);
const AdObject object = ad.search_object(group_dn);
const QList<QString> member_list = object.get_strings(ATTRIBUTE_MEMBER);
QCOMPARE(member_list, QList<QString>({user_dn}));
// Check ui state after applying (just in case)
QCOMPARE(model->rowCount(), 1);
QCOMPARE(model->item(0, 0)->text(), dn_get_name(user_dn));
}
QTEST_MAIN(ADMCTestMembersTab)
| 3,938
|
C++
|
.cpp
| 96
| 37.34375
| 164
| 0.723198
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,553
|
admc_test_gplink.cpp
|
altlinux_admc/tests/admc_test_gplink.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_gplink.h"
#include "gplink.h"
Q_DECLARE_METATYPE(GplinkOption)
const QString test_gplink_string = "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;0][LDAP://cn={BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB},cn=policies,cn=system,DC=foodomain,DC=com;1][LDAP://cn={CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC},cn=policies,cn=system,DC=foodomain,DC=com;2]";
const QString dn_A = "CN={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},CN=Policies,CN=System,DC=foodomain,DC=com";
const QString dn_B = "CN={BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB},CN=Policies,CN=System,DC=foodomain,DC=com";
const QString dn_C = "CN={CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC},CN=Policies,CN=System,DC=foodomain,DC=com";
const QString gplink_A = "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;0]";
const QString gplink_B = "[LDAP://cn={BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB},cn=policies,cn=system,DC=foodomain,DC=com;1]";
const QString gplink_C = "[LDAP://cn={CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC},cn=policies,cn=system,DC=foodomain,DC=com;2]";
void ADMCTestGplink::initTestCase() {
}
void ADMCTestGplink::cleanupTestCase() {
}
void ADMCTestGplink::init() {
}
void ADMCTestGplink::cleanup() {
}
void ADMCTestGplink::to_string() {
Gplink gplink(test_gplink_string);
QCOMPARE(gplink.to_string(), test_gplink_string);
}
void ADMCTestGplink::equals() {
Gplink gplink_1(test_gplink_string);
Gplink gplink_2(test_gplink_string);
QCOMPARE(gplink_1.to_string(), gplink_2.to_string());
}
void ADMCTestGplink::contains_data() {
QTest::addColumn<QString>("gpo");
QTest::addColumn<bool>("contains_value");
QTest::newRow("a") << dn_A << true;
QTest::newRow("b") << dn_B << true;
QTest::newRow("c") << dn_C << true;
QTest::newRow("shouldn't contains") << "CN={00000000-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=Dystem,DC=foodomain,DC=com" << false;
}
void ADMCTestGplink::contains() {
QFETCH(QString, gpo);
QFETCH(bool, contains_value);
Gplink gplink(test_gplink_string);
QCOMPARE(gplink.contains(gpo), contains_value);
}
void ADMCTestGplink::add_data() {
QTest::addColumn<QString>("gplink_before");
QTest::addColumn<QList<QString>>("gpo_list");
QTest::addColumn<QString>("gplink_after");
QTest::newRow("add to empty") << "" << QList<QString>({dn_A}) << gplink_A;
QTest::newRow("add to non-empty") << gplink_B << QList<QString>({dn_A}) << (gplink_A + gplink_B);
QTest::newRow("add same one twice to empty") << "" << QList<QString>({dn_A, dn_A}) << gplink_A;
QTest::newRow("add already existing") << gplink_A << QList<QString>({dn_A}) << gplink_A;
}
void ADMCTestGplink::add() {
QFETCH(QString, gplink_before);
QFETCH(QList<QString>, gpo_list);
QFETCH(QString, gplink_after);
Gplink gplink(gplink_before);
for (const QString &gpo : gpo_list) {
gplink.add(gpo);
}
QCOMPARE(gplink.to_string(), gplink_after);
}
void ADMCTestGplink::remove_data() {
QTest::addColumn<QString>("gplink_before");
QTest::addColumn<QList<QString>>("gpo_list");
QTest::addColumn<QString>("gplink_after");
QTest::newRow("remove 1") << gplink_A << QList<QString>({dn_A}) << "";
QTest::newRow("remove from empty") << "" << QList<QString>({dn_A}) << "";
QTest::newRow("remove same one twice") << gplink_A << QList<QString>({dn_A, dn_A}) << "";
QTest::newRow("remove from multiple") << (gplink_A + gplink_B) << QList<QString>({dn_A}) << gplink_B;
}
void ADMCTestGplink::remove() {
QFETCH(QString, gplink_before);
QFETCH(QList<QString>, gpo_list);
QFETCH(QString, gplink_after);
Gplink gplink(gplink_before);
for (const QString &gpo : gpo_list) {
gplink.remove(gpo);
}
QCOMPARE(gplink.to_string(), gplink_after);
}
void ADMCTestGplink::move_up_data() {
QTest::addColumn<QString>("gplink_before");
QTest::addColumn<QList<QString>>("gpo_list");
QTest::addColumn<QString>("gplink_after");
QTest::newRow("move up empty") << "" << QList<QString>({dn_A}) << "";
QTest::newRow("move up single") << gplink_A << QList<QString>({dn_A}) << gplink_A;
QTest::newRow("move up non-existing") << gplink_A << QList<QString>({dn_B}) << gplink_A;
QTest::newRow("move up from [2] to [1]") << (gplink_A + gplink_B + gplink_C) << QList<QString>({dn_C}) << (gplink_A + gplink_B + gplink_C);
QTest::newRow("move up twice from [2] to [0]") << (gplink_A + gplink_B + gplink_C) << QList<QString>({dn_A, dn_A}) << (gplink_B + gplink_C + gplink_A);
}
void ADMCTestGplink::move_up() {
QFETCH(QString, gplink_before);
QFETCH(QList<QString>, gpo_list);
QFETCH(QString, gplink_after);
Gplink gplink(gplink_before);
for (const QString &gpo : gpo_list) {
gplink.move_up(gpo);
}
QCOMPARE(gplink.to_string(), gplink_after);
}
void ADMCTestGplink::move_down_data() {
QTest::addColumn<QString>("gplink_before");
QTest::addColumn<QList<QString>>("gpo_list");
QTest::addColumn<QString>("gplink_after");
QTest::newRow("move down empty") << "" << QList<QString>({dn_A}) << "";
QTest::newRow("move down single") << gplink_A << QList<QString>({dn_A}) << gplink_A;
QTest::newRow("move down non-existing") << gplink_A << QList<QString>({dn_B}) << gplink_A;
QTest::newRow("move down from [1] to [2]") << (gplink_A + gplink_B + gplink_C) << QList<QString>({dn_B}) << (gplink_B + gplink_A + gplink_C);
QTest::newRow("move down twice from [0] to [2]") << (gplink_A + gplink_B + gplink_C) << QList<QString>({dn_C, dn_C}) << (gplink_C + gplink_A + gplink_B);
}
void ADMCTestGplink::move_down() {
QFETCH(QString, gplink_before);
QFETCH(QList<QString>, gpo_list);
QFETCH(QString, gplink_after);
Gplink gplink(gplink_before);
for (const QString &gpo : gpo_list) {
gplink.move_down(gpo);
}
QCOMPARE(gplink.to_string(), gplink_after);
}
void ADMCTestGplink::get_option_data() {
QTest::addColumn<QString>("gplink_before");
QTest::addColumn<QString>("gpo");
QTest::addColumn<GplinkOption>("option");
QTest::addColumn<bool>("option_value");
QTest::newRow("A disabled") << gplink_A << dn_A << GplinkOption_Disabled << false;
QTest::newRow("A enforced") << gplink_A << dn_A << GplinkOption_Enforced << false;
QTest::newRow("B disabled") << gplink_B << dn_B << GplinkOption_Disabled << true;
QTest::newRow("B enforced") << gplink_B << dn_B << GplinkOption_Enforced << false;
QTest::newRow("C disabled") << gplink_C << dn_C << GplinkOption_Disabled << false;
QTest::newRow("C enforced") << gplink_C << dn_C << GplinkOption_Enforced << true;
}
void ADMCTestGplink::get_option() {
QFETCH(QString, gplink_before);
QFETCH(QString, gpo);
QFETCH(GplinkOption, option);
QFETCH(bool, option_value);
Gplink gplink(gplink_before);
const bool actual_value = gplink.get_option(gpo, option);
QCOMPARE(actual_value, option_value);
}
void ADMCTestGplink::set_option_data() {
QTest::addColumn<QString>("gplink_before");
QTest::addColumn<QString>("gpo");
QTest::addColumn<GplinkOption>("option");
QTest::addColumn<bool>("option_value");
QTest::addColumn<QString>("gplink_after");
QTest::newRow("set disabled true") << "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;0]" << dn_A << GplinkOption_Disabled << true << "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;1]";
QTest::newRow("set enforced true") << "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;0]" << dn_A << GplinkOption_Enforced << true << "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;2]";
QTest::newRow("set disabled false") << "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;1]" << dn_A << GplinkOption_Disabled << false << "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;0]";
QTest::newRow("set enforced false") << "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;2]" << dn_A << GplinkOption_Enforced << false << "[LDAP://cn={AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA},cn=policies,cn=system,DC=foodomain,DC=com;0]";
}
void ADMCTestGplink::set_option() {
QFETCH(QString, gplink_before);
QFETCH(QString, gpo);
QFETCH(GplinkOption, option);
QFETCH(bool, option_value);
QFETCH(QString, gplink_after);
Gplink gplink(gplink_before);
gplink.set_option(gpo, option, option_value);
QCOMPARE(gplink.to_string(), gplink_after);
}
void ADMCTestGplink::get_gpo_list_data() {
QTest::addColumn<QList<QString>>("input");
QTest::addColumn<QList<QString>>("expected_output");
const QString dn_ldap_case = dn_A;
const QString dn_lower_case = dn_ldap_case.toLower();
const QString dn_upper_case = dn_ldap_case.toUpper();
QTest::newRow("LDAP case") << QList<QString>({dn_ldap_case}) << QList<QString>({dn_ldap_case});
QTest::newRow("lower case") << QList<QString>({dn_lower_case}) << QList<QString>({dn_ldap_case});
QTest::newRow("upper case") << QList<QString>({dn_lower_case}) << QList<QString>({dn_ldap_case});
}
void ADMCTestGplink::get_gpo_list() {
QFETCH(QList<QString>, input);
QFETCH(QList<QString>, expected_output);
Gplink gplink;
for (const QString &gpo : input) {
gplink.add(gpo);
}
const QList<QString> actual_output = gplink.get_gpo_list();
QCOMPARE(actual_output, expected_output);
}
void ADMCTestGplink::get_gpo_order_data() {
QTest::addColumn<QList<QString>>("input");
QTest::addColumn<QString>("target_gpo");
QTest::addColumn<int>("expected_order");
const QList<QString> gpo_list = {
dn_A,
dn_B,
dn_C,
};
QTest::newRow("A") << gpo_list << dn_A << 1;
QTest::newRow("B") << gpo_list << dn_B << 2;
QTest::newRow("C") << gpo_list << dn_C << 3;
}
void ADMCTestGplink::get_gpo_order() {
QFETCH(QList<QString>, input);
QFETCH(QString, target_gpo);
QFETCH(int, expected_order);
Gplink gplink;
for (const QString &gpo : input) {
gplink.add(gpo);
}
const int actual_order = gplink.get_gpo_order(target_gpo);
QCOMPARE(actual_order, expected_order);
}
QTEST_MAIN(ADMCTestGplink)
| 11,235
|
C++
|
.cpp
| 225
| 45.76
| 320
| 0.678643
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,554
|
admc_test_policy_results_widget.cpp
|
altlinux_admc/tests/admc_test_policy_results_widget.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_policy_results_widget.h"
#include "ad_filter.h"
#include "console_widget/results_view.h"
#include "globals.h"
#include "gplink.h"
#include "results_widgets/policy_results_widget.h"
#include "utils.h"
#include <QStandardItemModel>
#include <QTreeView>
// NOTE: unlike other tests, here we have to create the test
// thing (gpo) once and reuse between tests because creating
// and deleting gpo's takes too much time. If we did that
// for every test they would take forever.
const QString gpo_name = "test_policy_for_admc_test_results_widget";
void ADMCTestPolicyResultsWidget::initTestCase() {
ADMCTest::initTestCase();
const bool gpo_add_success = ad.gpo_add(gpo_name, gpo);
QVERIFY(gpo_add_success);
}
void ADMCTestPolicyResultsWidget::cleanupTestCase() {
ADMCTest::cleanupTestCase();
// Delete old test-policy, if needed
const QString base = g_adconfig->domain_dn();
const QString filter = filter_CONDITION(Condition_Equals, ATTRIBUTE_DISPLAY_NAME, gpo_name);
const QList<QString> attributes = QList<QString>();
const QHash<QString, AdObject> search_results = ad.search(base, SearchScope_All, filter, attributes);
for (const QString &dn : search_results.keys()) {
bool deleted_object;
ad.gpo_delete(dn, &deleted_object);
}
}
void ADMCTestPolicyResultsWidget::init() {
ADMCTest::init();
widget = new PolicyResultsWidget(parent_widget);
add_widget(widget);
ResultsView *results_view = widget->get_view();
view = results_view->detail_view();
model = widget->findChild<QStandardItemModel *>();
QVERIFY(model);
}
void ADMCTestPolicyResultsWidget::load_empty() {
widget->update(gpo);
QCOMPARE(view->model()->rowCount(), 0);
}
void ADMCTestPolicyResultsWidget::load() {
// Link gpo to ou
const QString ou_dn = test_object_dn(TEST_OU, CLASS_OU);
const bool create_ou_success = ad.object_add(ou_dn, CLASS_OU);
QVERIFY(create_ou_success);
const AdObject ou_object = ad.search_object(ou_dn);
const QString gplink_string = ou_object.get_string(ATTRIBUTE_GPLINK);
Gplink gplink = Gplink(gplink_string);
gplink.add(gpo);
gplink.set_option(gpo, GplinkOption_Enforced, true);
ad.attribute_replace_string(ou_dn, ATTRIBUTE_GPLINK, gplink.to_string());
widget->update(gpo);
QCOMPARE(model->rowCount(), 1);
QCOMPARE(model->columnCount(), 4);
QList<QStandardItem *> item_list;
for (int col = 0; col < 4; col++) {
QStandardItem *item = model->item(0, col);
QVERIFY(item);
item_list.append(item);
}
QCOMPARE(item_list[0]->text(), TEST_OU);
QCOMPARE(item_list[1]->checkState(), Qt::Checked);
QCOMPARE(item_list[2]->checkState(), Qt::Unchecked);
QCOMPARE(item_list[3]->text(), dn_get_parent_canonical(ou_dn));
}
void ADMCTestPolicyResultsWidget::delete_link() {
const QString ou_dn = test_object_dn(TEST_OU, CLASS_OU);
const bool create_ou_success = ad.object_add(ou_dn, CLASS_OU);
QVERIFY(create_ou_success);
// Link gpo to ou
{
const QString modified_gplink_string = [&]() {
const AdObject ou_object = ad.search_object(ou_dn);
const QString gplink_string = ou_object.get_string(ATTRIBUTE_GPLINK);
Gplink gplink = Gplink(gplink_string);
gplink.add(gpo);
const QString out = gplink.to_string();
return out;
}();
const bool modify_gplink_success = ad.attribute_replace_string(ou_dn, ATTRIBUTE_GPLINK, modified_gplink_string);
QVERIFY(modify_gplink_success);
}
widget->update(gpo);
QCOMPARE(model->rowCount(), 1);
const QStandardItem *ou_item = model->item(0, 0);
QVERIFY(ou_item);
// Select policy so it's used for remove operation
QItemSelectionModel *selection_model = view->selectionModel();
const QModelIndex ou_index = ou_item->index();
selection_model->select(ou_index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
widget->delete_link();
// Check that gpo is removed from model
QCOMPARE(model->rowCount(), 0);
const bool updated_gplink_contains_gpo = [&]() {
const AdObject ou_object = ad.search_object(ou_dn);
const QString gplink_string = ou_object.get_string(ATTRIBUTE_GPLINK);
const Gplink updated_gplink = Gplink(gplink_string);
const bool out = updated_gplink.contains(gpo);
return out;
}();
QCOMPARE(updated_gplink_contains_gpo, false);
}
QTEST_MAIN(ADMCTestPolicyResultsWidget)
| 5,336
|
C++
|
.cpp
| 126
| 37.555556
| 120
| 0.702938
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,555
|
admc_test_select_classes_widget.cpp
|
altlinux_admc/tests/admc_test_select_classes_widget.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_select_classes_widget.h"
#include "filter_widget/class_filter_dialog.h"
#include "filter_widget/select_classes_widget.h"
#include "filter_widget/ui_class_filter_dialog.h"
#include "filter_widget/ui_select_classes_widget.h"
void ADMCTestSelectClassesWidget::init() {
ADMCTest::init();
select_classes_widget = new SelectClassesWidget();
select_classes_widget->set_classes(filter_classes, filter_classes);
select_classes_widget->enable_filtering_all_classes();
add_widget(select_classes_widget);
select_button = select_classes_widget->ui->select_button;
classes_display = select_classes_widget->ui->classes_display;
}
void ADMCTestSelectClassesWidget::test_foo_data() {
QTest::addColumn<bool>("all_checked");
QTest::addColumn<QList<QString>>("specific_classes_checked");
QTest::addColumn<QString>("correct_display_string");
QTest::addColumn<QString>("correct_filter");
// clang-format off
QTest::newRow("all only") << true << QList<QString>() << "All" << "";
// NOTE: all should override other checkboxes, even
// if they are checked
QTest::newRow("all + some specific") << true << QList<QString>({"User", "Group"}) << "All" << "";
QTest::newRow("User") << false << QList<QString>({"User"}) << "User" << "(objectClass=user)";
QTest::newRow("User + Group") << false << QList<QString>({"User", "Group"}) << "Group, User" << "(|(objectClass=user)(objectClass=group))";
// clang-format on
}
void ADMCTestSelectClassesWidget::test_foo() {
QFETCH(bool, all_checked);
QFETCH(QList<QString>, specific_classes_checked);
QFETCH(QString, correct_display_string);
QFETCH(QString, correct_filter);
auto check_output_correctness = [&]() {
QCOMPARE(classes_display->text(), correct_display_string);
QCOMPARE(select_classes_widget->get_filter(), correct_filter);
};
auto get_class_checkbox_list = [](ClassFilterDialog *dialog) {
ClassFilterWidget *class_filter_widget = dialog->ui->class_filter_widget;
const QList<QCheckBox *> out = class_filter_widget->findChildren<QCheckBox *>();
return out;
};
// Check correctness of input->output
select_button->click();
ClassFilterDialog *class_filter_dialog = select_classes_widget->findChild<ClassFilterDialog *>();
QVERIFY(class_filter_dialog);
QVERIFY(QTest::qWaitForWindowExposed(class_filter_dialog, 1000));
QCheckBox *all_checkbox = class_filter_dialog->ui->all_checkbox;
all_checkbox->setChecked(all_checked);
const QList<QCheckBox *> class_checkbox_list = get_class_checkbox_list(class_filter_dialog);
for (QCheckBox *check : class_checkbox_list) {
const bool match = specific_classes_checked.contains(check->text());
check->setChecked(match);
}
class_filter_dialog->accept();
check_output_correctness();
// Check state saving/restoring
const QVariant state = select_classes_widget->save_state();
select_classes_widget->restore_state(state);
check_output_correctness();
// Check that reopening dialog retains state
select_button->click();
ClassFilterDialog *class_filter_dialog_2 = select_classes_widget->findChild<ClassFilterDialog *>();
QVERIFY(class_filter_dialog_2);
QVERIFY(QTest::qWaitForWindowExposed(class_filter_dialog_2, 1000));
class_filter_dialog_2->accept();
check_output_correctness();
}
QTEST_MAIN(ADMCTestSelectClassesWidget)
| 4,249
|
C++
|
.cpp
| 88
| 43.875
| 143
| 0.716566
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,556
|
admc_test_password_edit.cpp
|
altlinux_admc/tests/admc_test_password_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_password_edit.h"
#include "attribute_edits/password_edit.h"
#include <QCheckBox>
#include <QDateEdit>
#include <QFormLayout>
#include <QLineEdit>
// NOTE: no apply_unmodified() test because password edit
// always changes object when applying
void ADMCTestPasswordEdit::init() {
ADMCTest::init();
main_edit = new QLineEdit(parent_widget);
confirm_edit = new QLineEdit(parent_widget);
auto show_password_check = new QCheckBox(parent_widget);
edit = new PasswordEdit(main_edit, confirm_edit, show_password_check, parent_widget);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
void ADMCTestPasswordEdit::edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
main_edit->setText("test");
QVERIFY(edited_signal_emitted);
}
void ADMCTestPasswordEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QVERIFY(main_edit->text().isEmpty());
QVERIFY(confirm_edit->text().isEmpty());
}
void ADMCTestPasswordEdit::verify_data() {
QTest::addColumn<QString>("main_pass");
QTest::addColumn<QString>("confirm_pass");
QTest::newRow("mismatch") << "test"
<< "no-match";
QTest::newRow("empty") << QString() << QString();
}
void ADMCTestPasswordEdit::verify() {
QFETCH(QString, main_pass);
QFETCH(QString, confirm_pass);
main_edit->setText(main_pass);
confirm_edit->setText(confirm_pass);
const bool verify_success = edit->verify(ad, dn);
QCOMPARE(verify_success, false);
QCOMPARE(message_box_is_open(), true);
}
void ADMCTestPasswordEdit::apply() {
load();
main_edit->setText("pass123!");
confirm_edit->setText("pass123!");
const QByteArray pwdLastSet_value_before = [=]() {
const AdObject object = ad.search_object(dn);
return object.get_value(ATTRIBUTE_PWD_LAST_SET);
}();
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const QByteArray pwdLastSet_value_after = [=]() {
const AdObject object = ad.search_object(dn);
return object.get_value(ATTRIBUTE_PWD_LAST_SET);
}();
QVERIFY(pwdLastSet_value_after != pwdLastSet_value_before);
}
QTEST_MAIN(ADMCTestPasswordEdit)
| 3,322
|
C++
|
.cpp
| 89
| 32.88764
| 89
| 0.698472
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,557
|
admc_test_string_large_edit.cpp
|
altlinux_admc/tests/admc_test_string_large_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_string_large_edit.h"
#include "attribute_edits/string_large_edit.h"
#include <QFormLayout>
#include <QPlainTextEdit>
#define TEST_ATTRIBUTE ATTRIBUTE_FIRST_NAME
void ADMCTestStringLargeEdit::init() {
ADMCTest::init();
text_edit = new QPlainTextEdit(parent_widget);
edit = new StringLargeEdit(text_edit, TEST_ATTRIBUTE, parent_widget);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
// edited() signal should be emitted when lineedit is edited
void ADMCTestStringLargeEdit::test_emit_edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
text_edit->setPlainText("test");
QVERIFY(edited_signal_emitted);
}
// Edit should contain current attribute value after load()
// call
void ADMCTestStringLargeEdit::load() {
const QString test_value = "test value";
// Set attribute value
ad.attribute_replace_string(dn, TEST_ATTRIBUTE, test_value);
// Load user into edit
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const QString edit_value = text_edit->toPlainText();
;
QCOMPARE(edit_value, test_value);
}
void ADMCTestStringLargeEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
// Edit should do change attribute to value
void ADMCTestStringLargeEdit::apply() {
const QString new_value = "new value";
text_edit->setPlainText(new_value);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object = ad.search_object(dn);
const QString current_value = object.get_string(TEST_ATTRIBUTE);
QCOMPARE(current_value, new_value);
}
QTEST_MAIN(ADMCTestStringLargeEdit)
| 2,738
|
C++
|
.cpp
| 73
| 33.808219
| 73
| 0.728647
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,558
|
admc_test_logon_hours_dialog.cpp
|
altlinux_admc/tests/admc_test_logon_hours_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_logon_hours_dialog.h"
#include "attribute_edits/logon_hours_dialog.h"
#include "attribute_edits/ui_logon_hours_dialog.h"
#include <QRadioButton>
#include <QStandardItemModel>
#include <QTableView>
void ADMCTestLogonHoursDialog::open_dialog(const QByteArray &value) {
dialog = new LogonHoursDialog(value, parent_widget);
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
local_time_button = dialog->ui->local_time_button;
utc_time_button = dialog->ui->utc_time_button;
view = dialog->ui->view;
model = dialog->findChild<QStandardItemModel *>();
QVERIFY(model);
selection_model = view->selectionModel();
}
auto empty_day = []() {
QList<bool> out;
for (int i = 0; i < HOURS_IN_DAY; i++) {
out.append(false);
}
return out;
};
auto empty_week = []() {
QList<QList<bool>> out;
for (int day = 0; day < DAYS_IN_WEEK; day++) {
out.append(empty_day());
}
return out;
};
const QByteArray empty_bytes = QByteArray(LOGON_HOURS_SIZE, '\0');
const QByteArray test_bytes = []() {
QByteArray out = empty_bytes;
out[Weekday_Tuesday * 3] = 'a';
return out;
}();
const QList<QList<bool>> test_bools = []() {
QList<QList<bool>> out = empty_week();
out[Weekday_Tuesday][0] = true;
out[Weekday_Tuesday][5] = true;
out[Weekday_Tuesday][6] = true;
return out;
}();
void ADMCTestLogonHoursDialog::conversion_funs() {
const QList<QList<bool>> converted_bools = logon_hours_to_bools(test_bytes);
QCOMPARE(converted_bools, test_bools);
const QByteArray converted_bytes = logon_hours_to_bytes(test_bools);
QCOMPARE(converted_bytes, test_bytes);
}
void ADMCTestLogonHoursDialog::load_data() {
QTest::addColumn<QByteArray>("value");
QTest::newRow("empty") << empty_bytes;
QTest::newRow("non-empty") << test_bytes;
}
void ADMCTestLogonHoursDialog::load() {
QFETCH(QByteArray, value);
open_dialog(value);
utc_time_button->setChecked(true);
const QByteArray actual_value = dialog->get();
QCOMPARE(actual_value, value);
}
void ADMCTestLogonHoursDialog::select() {
open_dialog(test_bytes);
utc_time_button->setChecked(true);
const QList<QModelIndex> selected = selection_model->selectedIndexes();
const QSet<QModelIndex> selected_set = QSet<QModelIndex>(selected.begin(), selected.end());
const QSet<QModelIndex> correct_selected_set = {
model->index(2, 0),
model->index(2, 5),
model->index(2, 6),
};
QCOMPARE(selected_set, correct_selected_set);
}
void ADMCTestLogonHoursDialog::load_empty() {
open_dialog(QByteArray());
const QByteArray actual_value = dialog->get();
const QByteArray expected_value = QByteArray();
QCOMPARE(actual_value, expected_value);
}
void ADMCTestLogonHoursDialog::handle_timezone() {
const QByteArray bytes = [&]() {
QByteArray out = empty_bytes;
out[Weekday_Tuesday * 3] = 0x01;
return out;
}();
open_dialog(bytes);
// First do UTC
utc_time_button->setChecked(true);
const QList<QModelIndex> correct_utc_selected = {
model->index(Weekday_Tuesday, 0),
};
const QList<QModelIndex> utc_selected = selection_model->selectedIndexes();
QCOMPARE(utc_selected, correct_utc_selected);
// Then local time
local_time_button->setChecked(true);
const QList<QModelIndex> correct_local_selected = [&]() {
// UTC rows
int row = Weekday_Tuesday;
int col = 0;
// Apply timezone offset
const int offset = get_current_utc_offset();
col += offset;
if (col < 0) {
col += HOURS_IN_DAY;
row--;
} else if (col >= HOURS_IN_DAY) {
col -= HOURS_IN_DAY;
row++;
}
return QList<QModelIndex>({model->index(row, col)});
}();
const QList<QModelIndex> local_selected = selection_model->selectedIndexes();
QCOMPARE(local_selected, correct_local_selected);
}
QTEST_MAIN(ADMCTestLogonHoursDialog)
| 4,855
|
C++
|
.cpp
| 135
| 31.177778
| 95
| 0.679205
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,559
|
admc_test_logon_computers_edit.cpp
|
altlinux_admc/tests/admc_test_logon_computers_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_logon_computers_edit.h"
#include "attribute_edits/logon_computers_dialog.h"
#include "attribute_edits/logon_computers_edit.h"
#include "attribute_edits/ui_logon_computers_dialog.h"
#include <QFormLayout>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
// TODO: make this less messy, maybe test dialog
// separately. Should end up without needing to use
// load_and_open_dialog()
void ADMCTestLogonComputersEdit::init() {
ADMCTest::init();
open_dialog_button = new QPushButton(parent_widget);
edit = new LogonComputersEdit(open_dialog_button, parent_widget);
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
void ADMCTestLogonComputersEdit::load_empty() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
open_dialog();
QCOMPARE(list->count(), 0);
}
void ADMCTestLogonComputersEdit::load() {
load_and_open_dialog();
QCOMPARE(list->count(), 2);
test_list_item(0, "test");
test_list_item(1, "value");
}
void ADMCTestLogonComputersEdit::emit_edited_signal() {
load_and_open_dialog();
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
dialog->accept();
QVERIFY(edited_signal_emitted);
}
void ADMCTestLogonComputersEdit::add() {
load_and_open_dialog();
value_edit->setText("new");
add_button->click();
QCOMPARE(list->count(), 3);
test_list_item(0, "test");
test_list_item(1, "value");
test_list_item(2, "new");
}
void ADMCTestLogonComputersEdit::remove() {
load_and_open_dialog();
list->setCurrentRow(0);
remove_button->click();
QCOMPARE(list->count(), 1);
test_list_item(0, "value");
}
void ADMCTestLogonComputersEdit::test_list_item(const int row, const QString &text) {
load_and_open_dialog();
auto item = list->item(row);
QVERIFY(item);
QCOMPARE(item->text(), text);
}
void ADMCTestLogonComputersEdit::apply_unmodified() {
load_and_open_dialog();
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestLogonComputersEdit::apply() {
load_and_open_dialog();
value_edit->setText("new");
add_button->click();
dialog->accept();
edit->apply(ad, dn);
const AdObject updated_object = ad.search_object(dn);
const QString updated_value = updated_object.get_string(ATTRIBUTE_USER_WORKSTATIONS);
QCOMPARE(updated_value, "test,value,new");
}
void ADMCTestLogonComputersEdit::load_and_open_dialog() {
const QString test_value = "test,value";
ad.attribute_replace_string(dn, ATTRIBUTE_USER_WORKSTATIONS, test_value);
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
open_dialog();
}
void ADMCTestLogonComputersEdit::open_dialog() {
open_dialog_button->click();
dialog = parent_widget->findChild<LogonComputersDialog *>();
QVERIFY(dialog);
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
list = dialog->ui->list;
value_edit = dialog->ui->edit;
add_button = dialog->ui->add_button;
remove_button = dialog->ui->remove_button;
}
QTEST_MAIN(ADMCTestLogonComputersEdit)
| 4,129
|
C++
|
.cpp
| 117
| 31.384615
| 89
| 0.711587
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,560
|
admc_test_find_object_dialog.cpp
|
altlinux_admc/tests/admc_test_find_object_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_find_object_dialog.h"
#include "adldap.h"
#include "filter_widget/filter_widget_advanced_tab.h"
#include "filter_widget/filter_widget_simple_tab.h"
#include "filter_widget/ui_filter_widget.h"
#include "filter_widget/ui_filter_widget_advanced_tab.h"
#include "filter_widget/ui_filter_widget_simple_tab.h"
#include "find_widgets/find_object_dialog.h"
#include "find_widgets/find_widget.h"
#include "ui_find_object_dialog.h"
#include "ui_find_widget.h"
#include <QTreeView>
void ADMCTestFindObjectDialog::simple_tab() {
const QString parent = test_arena_dn();
const QString user_name = TEST_USER;
const QString user_dn = test_object_dn(user_name, CLASS_USER);
// Create test user
const bool create_user_success = ad.object_add(user_dn, CLASS_USER);
QVERIFY2(create_user_success, "Failed to create user");
QVERIFY2(object_exists(user_dn), "Created user doesn't exist");
auto find_dialog = new FindObjectDialog(nullptr, parent, parent_widget);
find_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(find_dialog, 1000));
FindWidget *find_widget = find_dialog->ui->find_widget;
// Enter name in search field
FilterWidgetSimpleTab *simple_tab = find_widget->ui->filter_widget->ui->simple_tab;
simple_tab->ui->name_edit->setText(user_name);
// Press find button
QPushButton *find_button = find_widget->ui->find_button;
find_button->click();
// Confirm that results are not empty
auto find_results = find_dialog->findChild<QTreeView *>();
wait_for_find_results_to_load(find_results);
QVERIFY2(find_results->model()->rowCount(), "No results found");
}
void ADMCTestFindObjectDialog::advanced_tab() {
const QString parent = test_arena_dn();
const QString user_name = TEST_USER;
const QString user_dn = test_object_dn(user_name, CLASS_USER);
// Create test user
const bool create_user_success = ad.object_add(user_dn, CLASS_USER);
QVERIFY2(create_user_success, "Failed to create user");
QVERIFY2(object_exists(user_dn), "Created user doesn't exist");
auto find_dialog = new FindObjectDialog(nullptr, parent, parent_widget);
find_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(find_dialog, 1000));
FilterWidget *filter_widget = find_dialog->ui->find_widget->ui->filter_widget;
QTabWidget *tab_widget = filter_widget->ui->tab_widget;
FilterWidgetAdvancedTab *advanced_tab = filter_widget->ui->advanced_tab;
tab_widget->setCurrentWidget(advanced_tab);
QPlainTextEdit *ldap_filter_edit = advanced_tab->ui->ldap_filter_edit;
const QString filter = filter_CONDITION(Condition_Equals, ATTRIBUTE_DN, user_dn);
ldap_filter_edit->setPlainText(filter);
QPushButton *find_button = find_dialog->ui->find_widget->ui->find_button;
find_button->click();
auto find_results = find_dialog->findChild<QTreeView *>();
wait_for_find_results_to_load(find_results);
QVERIFY2(find_results->model()->rowCount(), "No results found");
}
QTEST_MAIN(ADMCTestFindObjectDialog)
| 3,832
|
C++
|
.cpp
| 79
| 44.797468
| 87
| 0.736927
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,561
|
admc_test_attributes_tab.cpp
|
altlinux_admc/tests/admc_test_attributes_tab.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_attributes_tab.h"
#include "attribute_dialogs/list_attribute_dialog.h"
#include "attribute_dialogs/string_attribute_dialog.h"
#include "attribute_dialogs/ui_list_attribute_dialog.h"
#include "attribute_dialogs/ui_string_attribute_dialog.h"
#include "tabs/ui_attributes_tab.h"
#include <QDialog>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QString>
#include <QTreeView>
#include <QVBoxLayout>
Q_DECLARE_METATYPE(AttributeFilter)
// NOTE: can't be set because order is important. Read only
// has to be set first to enable other filters.
const QList<AttributeFilter> all_filters = {
AttributeFilter_Unset,
AttributeFilter_ReadOnly,
AttributeFilter_Mandatory,
AttributeFilter_Optional,
AttributeFilter_SystemOnly,
AttributeFilter_Constructed,
AttributeFilter_Backlink,
};
void ADMCTestAttributesTab::init() {
ADMCTest::init();
view = new QTreeView(parent_widget);
filter_button = new QPushButton(parent_widget);
edit_button = new QPushButton(parent_widget);
auto view_button = new QPushButton(parent_widget);
load_optional_attrs_button = new QPushButton(parent_widget);
edit = new AttributesTabEdit(view, filter_button, edit_button, view_button, load_optional_attrs_button, parent_widget);
filter_menu = view->findChild<AttributesTabFilterMenu *>();
QVERIFY(filter_menu);
model = edit->findChild<QStandardItemModel *>();
QVERIFY(model);
proxy = edit->findChild<QSortFilterProxyModel *>();
QVERIFY(proxy);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
// Load it into the tab
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
// NOTE: filters might be messed up in settings by user
// so reset it before tests
set_filter(all_filters, true);
}
void ADMCTestAttributesTab::cleanup() {
ADMCTest::cleanup();
edit_list.clear();
}
void ADMCTestAttributesTab::load() {
// Check that some attributes loaded correctly
auto check_value = [&](const QString &name, const QString &value) {
const QList<QStandardItem *> item_list = model->findItems(name);
if (item_list.size() != 1) {
return false;
}
QStandardItem *name_item = item_list[0];
QStandardItem *value_item = model->item(name_item->row(), 1);
const QString &this_value = value_item->text();
const bool value_is_correct = (this_value == value);
return value_is_correct;
};
check_value("name", TEST_USER);
check_value("distinguishedName", dn);
}
void ADMCTestAttributesTab::filter_data() {
QTest::addColumn<AttributeFilter>("filter");
QTest::addColumn<QString>("attribute");
QTest::newRow("unset") << AttributeFilter_Unset << ATTRIBUTE_HOME_PHONE;
QTest::newRow("read only") << AttributeFilter_ReadOnly << ATTRIBUTE_OBJECT_GUID;
QTest::newRow("system only") << AttributeFilter_SystemOnly << ATTRIBUTE_WHEN_CREATED;
QTest::newRow("constructed") << AttributeFilter_Constructed << "allowedAttributes";
QTest::newRow("backlink") << AttributeFilter_Backlink << ATTRIBUTE_MEMBER_OF;
QTest::newRow("mandatory") << AttributeFilter_Mandatory << "instanceType";
QTest::newRow("optional") << AttributeFilter_Optional << ATTRIBUTE_COUNTRY_CODE;
// NOTE: read only also needs to affect these read only
// attributes
QTest::newRow("read only allowed") << AttributeFilter_ReadOnly << "allowedAttributes";
QTest::newRow("read only when created") << AttributeFilter_ReadOnly << ATTRIBUTE_WHEN_CREATED;
QTest::newRow("read only member of") << AttributeFilter_ReadOnly << ATTRIBUTE_MEMBER_OF;
}
// Test filters by checking that affected attributes are
// visible/hidden when their filters are checked/unchecked
void ADMCTestAttributesTab::filter() {
QFETCH(AttributeFilter, filter);
QFETCH(QString, attribute);
auto check_filtering = [&](const bool should_be_visible) {
const QList<QStandardItem *> item_list = model->findItems(attribute);
QVERIFY2((item_list.size() == 1), qPrintable(QString("Failed to find attribute %1)").arg(attribute)));
QStandardItem *item = item_list[0];
const QModelIndex index = item->index();
const QModelIndex proxy_index = proxy->mapFromSource(index);
const bool is_visible = proxy_index.isValid();
const bool correct_filtering = (is_visible == should_be_visible);
QVERIFY2(correct_filtering, qPrintable(QString("filter = %1, attribute = %2, is_visible = %3, should_be_visible = %4").arg(filter).arg(attribute).arg(is_visible).arg(should_be_visible)));
};
// Disable(check) all filters (to filter nothing) and
// check that attribute is shown
set_filter(all_filters, true);
check_filtering(true);
// Enable(uncheck) filter and check that attribute is
// hidden
set_filter({filter}, false);
check_filtering(false);
// Reset after test is done
set_filter(all_filters, true);
}
// Change description attribute, apply and then confirm
// changes
void ADMCTestAttributesTab::apply() {
const QString correct_value = "test description";
navigate_until_object(view, "description", Qt::DisplayRole);
edit_button->click();
auto list_attribute_dialog = view->findChild<ListAttributeDialog *>();
QVERIFY(list_attribute_dialog);
QVERIFY(QTest::qWaitForWindowExposed(list_attribute_dialog, 1000));
QPushButton *add_button = list_attribute_dialog->ui->add_button;
add_button->click();
auto string_attribute_dialog = list_attribute_dialog->findChild<StringAttributeDialog *>();
QVERIFY(string_attribute_dialog);
QVERIFY(QTest::qWaitForWindowExposed(string_attribute_dialog, 1000));
QPlainTextEdit *string_attribute_dialog_edit = string_attribute_dialog->ui->edit;
string_attribute_dialog_edit->setPlainText(correct_value);
string_attribute_dialog->accept();
list_attribute_dialog->accept();
edit->apply(ad, dn);
const AdObject object = ad.search_object(dn);
const QString description_value = object.get_string(ATTRIBUTE_DESCRIPTION);
QCOMPARE(description_value, correct_value);
}
void ADMCTestAttributesTab::set_filter(const QList<AttributeFilter> &filter_list, const bool state) {
for (const AttributeFilter &filter : filter_list) {
QAction *action = filter_menu->findChild<QAction *>(QString::number(filter));
QVERIFY(action);
action->setChecked(state);
}
}
QTEST_MAIN(ADMCTestAttributesTab)
| 7,504
|
C++
|
.cpp
| 164
| 41.268293
| 195
| 0.724445
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,562
|
admc_test_account_option_edit.cpp
|
altlinux_admc/tests/admc_test_account_option_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_account_option_edit.h"
#include "attribute_edits/account_option_edit.h"
#include "globals.h"
#include <QCheckBox>
Q_DECLARE_METATYPE(AccountOption)
void ADMCTestAccountOptionEdit::init() {
ADMCTest::init();
const QList<AccountOption> option_list = [&]() {
QList<AccountOption> out;
for (int i = 0; i < AccountOption_COUNT; i++) {
const AccountOption option = (AccountOption) i;
out.append(option);
}
return out;
}();
for (const AccountOption &option : option_list) {
auto check = new QCheckBox(parent_widget);
auto edit = new AccountOptionEdit(check, option, parent_widget);
check_map[option] = check;
edit_map[option] = edit;
}
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
void ADMCTestAccountOptionEdit::test_emit_edited_signal() {
const AccountOption option = AccountOption_SmartcardRequired;
AccountOptionEdit *edit = edit_map[option];
QCheckBox *check = check_map[option];
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
check->setChecked(true);
QVERIFY(edited_signal_emitted);
}
void ADMCTestAccountOptionEdit::load_data() {
QTest::addColumn<AccountOption>("option");
QTest::addColumn<bool>("value");
QTest::newRow("disabled") << AccountOption_Disabled << true;
QTest::newRow("cant change pass") << AccountOption_CantChangePassword << false;
QTest::newRow("pass expired") << AccountOption_PasswordExpired << true;
QTest::newRow("deskey") << AccountOption_UseDesKey << false;
QTest::newRow("smartcard") << AccountOption_SmartcardRequired << false;
QTest::newRow("cant delegate") << AccountOption_CantDelegate << false;
QTest::newRow("req preauth") << AccountOption_DontRequirePreauth << false;
QTest::newRow("trusted") << AccountOption_TrustedForDelegation << false;
}
void ADMCTestAccountOptionEdit::load() {
QFETCH(AccountOption, option);
QFETCH(bool, value);
AccountOptionEdit *edit = edit_map[option];
QCheckBox *check = check_map[option];
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const bool edit_value = check->isChecked();
QCOMPARE(edit_value, value);
}
void ADMCTestAccountOptionEdit::apply_data() {
QTest::addColumn<AccountOption>("option");
QTest::newRow("disabled") << AccountOption_Disabled;
QTest::newRow("cant change pass") << AccountOption_CantChangePassword;
QTest::newRow("pass expired") << AccountOption_PasswordExpired;
QTest::newRow("deskey") << AccountOption_UseDesKey;
QTest::newRow("smartcard") << AccountOption_SmartcardRequired;
QTest::newRow("cant delegate") << AccountOption_CantDelegate;
QTest::newRow("req preauth") << AccountOption_DontRequirePreauth;
QTest::newRow("trusted") << AccountOption_TrustedForDelegation;
}
void ADMCTestAccountOptionEdit::apply() {
QFETCH(AccountOption, option);
AccountOptionEdit *edit = edit_map[option];
QCheckBox *check = check_map[option];
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const bool old_value = check->isChecked();
const bool new_value = !old_value;
check->setChecked(new_value);
edit->apply(ad, dn);
QCOMPARE(check->isChecked(), new_value);
const AdObject updated_object = ad.search_object(dn);
const bool value_in_object = updated_object.get_account_option(option, g_adconfig);
QCOMPARE(value_in_object, new_value);
}
void ADMCTestAccountOptionEdit::conflicts_data() {
QTest::addColumn<AccountOption>("subject");
QTest::addColumn<AccountOption>("blocker");
QTest::newRow("pass-expired blocks dont-expire-pass") << AccountOption_PasswordExpired << AccountOption_DontExpirePassword;
QTest::newRow("dont-expire-pass blocks pass-expired") << AccountOption_DontExpirePassword << AccountOption_PasswordExpired;
QTest::newRow("pass-expired blocks cant-change-pass") << AccountOption_PasswordExpired << AccountOption_CantChangePassword;
QTest::newRow("cant-change-pass blocks pass-expired") << AccountOption_CantChangePassword << AccountOption_PasswordExpired;
}
void ADMCTestAccountOptionEdit::conflicts() {
QFETCH(AccountOption, subject);
QFETCH(AccountOption, blocker);
account_option_setup_conflicts(check_map);
QCheckBox *subject_check = check_map[subject];
QCheckBox *blocker_check = check_map[blocker];
// Setup starting state
subject_check->setChecked(false);
blocker_check->setChecked(false);
// Check blocker
blocker_check->setChecked(true);
// Attempt to check subject, should get blocked
subject_check->click();
close_message_box();
QCOMPARE(subject_check->isChecked(), false);
// Attempt to check again, conflicts should be blocked
// every time
for (int i = 0; i < 3; i++) {
subject_check->click();
close_message_box();
QCOMPARE(subject_check->isChecked(), false);
}
}
QTEST_MAIN(ADMCTestAccountOptionEdit)
| 6,090
|
C++
|
.cpp
| 140
| 38.664286
| 127
| 0.714262
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,563
|
admc_test.cpp
|
altlinux_admc/tests/admc_test.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test.h"
#include "adldap.h"
#include "attribute_edits/attribute_edit.h"
#include "console_impls/object_impl.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/filter_widget_simple_tab.h"
#include "filter_widget/select_base_widget.h"
#include "filter_widget/ui_filter_widget.h"
#include "filter_widget/ui_filter_widget_simple_tab.h"
#include "filter_widget/ui_select_base_widget.h"
#include "find_widgets/find_widget.h"
#include "globals.h"
#include "select_dialogs/select_container_dialog.h"
#include "select_dialogs/select_object_advanced_dialog.h"
#include "select_dialogs/select_object_dialog.h"
#include "ui_find_widget.h"
#include "ui_select_container_dialog.h"
#include "ui_select_object_advanced_dialog.h"
#include "ui_select_object_dialog.h"
#include "utils.h"
#include "fsmo/fsmo_utils.h"
#include <QFormLayout>
#include <QLineEdit>
#include <QMessageBox>
#include <QModelIndex>
#include <QPushButton>
#include <QTest>
#include <QTimer>
#include <QTreeView>
#define PRINT_FOCUS_WIDGET_BEFORE_TAB false
#define PRINT_FOCUS_WIDGET_AFTER_TAB false
void ADMCTest::initTestCase() {
qRegisterMetaType<QHash<QString, AdObject>>("QHash<QString, AdObject>");
QVERIFY2(ad.is_connected(), "Failed to connect to AD server");
g_adconfig->load(ad, QLocale(QLocale::English));
AdInterface::set_config(g_adconfig);
if (!current_dc_is_master_for_role(ad, FSMORole_PDCEmulation)) {
connect_host_with_role(ad, FSMORole_PDCEmulation);
}
// Cleanup before all tests in-case this test suite was
// previously interrupted and a cleanup wasn't performed
cleanup();
}
void ADMCTest::cleanupTestCase() {
}
void ADMCTest::init() {
parent_widget = new QWidget();
layout = new QFormLayout();
parent_widget->setLayout(layout);
edits.clear();
const QString dn = test_arena_dn();
const bool create_success = ad.object_add(dn, CLASS_OU);
QVERIFY2(create_success, "Failed to create test-arena");
// Show parent widget and wait for it to appear
parent_widget->show();
QVERIFY(QTest::qWaitForWindowExposed(parent_widget, 1000));
}
void ADMCTest::cleanup() {
// Print AD error messages
if (ad.any_error_messages()) {
qInfo() << "AD errors:";
for (const auto &message : ad.messages()) {
if (message.type() == AdMessageType_Error) {
qInfo() << message.text();
}
}
}
ad.clear_messages();
if (parent_widget != nullptr) {
delete parent_widget;
parent_widget = nullptr;
}
// Delete test arena, if it exists
const QString dn = test_arena_dn();
const QHash<QString, AdObject> results = ad.search(dn, SearchScope_Object, QString(), QList<QString>());
const bool test_arena_exists = (results.size() == 1);
if (test_arena_exists) {
const bool delete_success = ad.object_delete(dn);
QVERIFY2(delete_success, "Failed to delete test-arena or it's contents");
QVERIFY2(!object_exists(dn), "Deleted test-arena still exists");
}
}
QString ADMCTest::test_arena_dn() {
const QString head_dn = g_adconfig->domain_dn();
const QString dn = QString("OU=test-arena,%1").arg(head_dn);
return dn;
}
QString ADMCTest::test_object_dn(const QString &name, const QString &object_class) {
const QString parent = test_arena_dn();
const QString dn = dn_from_name_and_parent(name, parent, object_class);
return dn;
}
bool ADMCTest::object_exists(const QString &dn) {
const QHash<QString, AdObject> results = ad.search(dn, SearchScope_Object, QString(), QList<QString>());
const bool exists = (results.size() == 1);
return exists;
}
// Go down the list of objects by pressing Down arrow
// until current item's dn equals to target dn
void navigate_until_object(QTreeView *view, const QString &target_dn, const int dn_role) {
QModelIndex prev_index;
QAbstractItemModel *model = view->model();
QList<QModelIndex> search_stack;
// NOTE: start at invalid index to iterate over top items
search_stack.append(QModelIndex());
while (!search_stack.isEmpty()) {
const QModelIndex index = search_stack.takeFirst();
const QString dn = index.data(dn_role).toString();
// NOTE: need to expand items because some models
// used in ADMC load the model dynamically from
// server as items are expanded (for example, the
// model used by move dialog)
const bool is_parent_of_object = (target_dn.contains(dn));
if (is_parent_of_object) {
view->expand(index);
}
const bool found_object = (dn == target_dn);
if (found_object) {
view->setCurrentIndex(index);
return;
}
for (int row = 0; row < model->rowCount(index); row++) {
const QModelIndex child = model->index(row, 0, index);
search_stack.append(child);
}
}
QFAIL(qPrintable(QString("Failed to navigate to object %1").arg(target_dn)));
}
void ADMCTest::wait_for_find_results_to_load(QTreeView *view) {
int timer = 0;
while (view->model()->rowCount() == 0) {
QTest::qWait(1);
timer++;
QVERIFY2((timer < 1000), "Find results failed to load, took too long");
}
}
void ADMCTest::close_message_box() {
auto message_box = parent_widget->findChild<QMessageBox *>();
if (message_box != nullptr) {
QVERIFY(QTest::qWaitForWindowExposed(message_box, 1000));
message_box->accept();
delete message_box;
}
}
bool ADMCTest::message_box_is_open() const {
auto message_box = parent_widget->findChild<QMessageBox *>();
const bool out = (message_box != nullptr);
return out;
}
void ADMCTest::select_in_select_dialog(SelectObjectDialog *select_dialog, const QString &dn) {
QPushButton *add_button = select_dialog->ui->add_button;
add_button->click();
// Find dialog has been opened, so switch to it
auto find_select_dialog = select_dialog->findChild<SelectObjectAdvancedDialog *>();
QVERIFY(find_select_dialog);
QVERIFY(QTest::qWaitForWindowExposed(find_select_dialog, 1000));
FindWidget *find_widget = find_select_dialog->ui->find_widget;
// Enter group name in "Name" edit
const QString name = dn_get_name(dn);
QLineEdit *name_edit = find_widget->ui->filter_widget->ui->simple_tab->ui->name_edit;
name_edit->setText(name);
// Press "Find" button
auto find_button = find_widget->ui->find_button;
find_button->click();
// Switch to find results
auto find_results_view = find_select_dialog->findChild<QTreeView *>();
QVERIFY(find_results_view);
wait_for_find_results_to_load(find_results_view);
// Select group in view
navigate_until_object(find_results_view, dn, ObjectRole_DN);
const QModelIndex selected_index = find_results_view->selectionModel()->currentIndex();
const QString selected_dn = selected_index.data(ObjectRole_DN).toString();
find_select_dialog->accept();
}
void ADMCTest::select_object_dialog_select(const QString &dn) {
auto select_dialog = parent_widget->findChild<SelectObjectDialog *>();
QVERIFY(select_dialog);
SelectBaseWidget *select_base_widget = select_dialog->ui->select_base_widget;
select_base_widget_add(select_base_widget, test_arena_dn());
QLineEdit *edit = select_dialog->ui->name_edit;
edit->setText(dn_get_name(dn));
QPushButton *add_button = select_dialog->ui->add_button;
add_button->click();
select_dialog->accept();
delete select_dialog;
}
void ADMCTest::add_widget(QWidget *widget) {
layout->addWidget(widget);
}
// Edit should do nothing if value wasn't modified
void ADMCTest::test_edit_apply_unmodified(AttributeEdit *edit, const QString &dn) {
const AdObject object_before = ad.search_object(dn);
edit->load(ad, object_before);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object_after = ad.search_object(dn);
QVERIFY(object_before.get_attributes_data() == object_after.get_attributes_data());
}
void ADMCTest::select_base_widget_add(SelectBaseWidget *widget, const QString &dn) {
QPushButton *browse_button = widget->ui->browse_button;
browse_button->click();
auto select_container_dialog = widget->findChild<SelectContainerDialog *>();
QVERIFY(select_container_dialog);
QVERIFY(QTest::qWaitForWindowExposed(select_container_dialog, 1000));
QTreeView *select_container_view = select_container_dialog->ui->view;
navigate_until_object(select_container_view, dn, ContainerRole_DN);
select_container_dialog->accept();
QVERIFY(QTest::qWaitForWindowExposed(widget, 1000));
}
void test_lineedit_autofill(QLineEdit *src_edit, QLineEdit *dest_edit) {
const QString expected_dest_text = "test";
src_edit->setText(expected_dest_text);
const QString actual_dest_text = dest_edit->text();
QCOMPARE(actual_dest_text, expected_dest_text);
}
| 9,812
|
C++
|
.cpp
| 234
| 37.25641
| 108
| 0.702146
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,564
|
admc_test_gpoptions_edit.cpp
|
altlinux_admc/tests/admc_test_gpoptions_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_gpoptions_edit.h"
#include "attribute_edits/gpoptions_edit.h"
#include <QCheckBox>
#include <QFormLayout>
#define TEST_ATTRIBUTE ATTRIBUTE_FIRST_NAME
void ADMCTestGpoptionsEdit::init() {
ADMCTest::init();
check = new QCheckBox(parent_widget);
edit = new GpoptionsEdit(check, parent_widget);
const QString name = TEST_OU;
dn = test_object_dn(name, CLASS_OU);
const bool create_success = ad.object_add(dn, CLASS_OU);
QVERIFY(create_success);
}
void ADMCTestGpoptionsEdit::test_emit_edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
check->setChecked(true);
QVERIFY(edited_signal_emitted);
}
void ADMCTestGpoptionsEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const QString edit_value = check->text();
;
QCOMPARE(check->isChecked(), false);
}
void ADMCTestGpoptionsEdit::apply() {
check->setChecked(true);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object = ad.search_object(dn);
const QString current_value = object.get_string(ATTRIBUTE_GPOPTIONS);
QCOMPARE(current_value, GPOPTIONS_BLOCK_INHERITANCE);
}
QTEST_MAIN(ADMCTestGpoptionsEdit)
| 2,161
|
C++
|
.cpp
| 59
| 32.932203
| 73
| 0.727098
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,565
|
admc_test_delegation_edit.cpp
|
altlinux_admc/tests/admc_test_delegation_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_delegation_edit.h"
#include "attribute_edits/delegation_edit.h"
#include "globals.h"
#include <QRadioButton>
void ADMCTestDelegationEdit::initTestCase_data() {
QTest::addColumn<bool>("use_on_button");
QTest::addColumn<bool>("is_on");
QTest::newRow("on") << true << true;
QTest::newRow("off") << false << false;
}
void ADMCTestDelegationEdit::init() {
ADMCTest::init();
auto on_button = new QRadioButton(parent_widget);
auto off_button = new QRadioButton(parent_widget);
edit = new DelegationEdit(off_button, on_button, parent_widget);
QFETCH_GLOBAL(bool, use_on_button);
button = [&]() {
if (use_on_button) {
return on_button;
} else {
return off_button;
}
}();
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
void ADMCTestDelegationEdit::emit_edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
button->click();
QVERIFY(edited_signal_emitted);
}
void ADMCTestDelegationEdit::load() {
QFETCH_GLOBAL(bool, is_on);
const bool success = ad.user_set_account_option(dn, AccountOption_TrustedForDelegation, is_on);
QVERIFY(success);
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QVERIFY(button->isChecked());
}
void ADMCTestDelegationEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestDelegationEdit::apply() {
QFETCH_GLOBAL(bool, is_on);
// First set current state to opposite
const bool success = ad.user_set_account_option(dn, AccountOption_TrustedForDelegation, !is_on);
QVERIFY(success);
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
button->click();
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject updated_object = ad.search_object(dn);
const bool updated_state = updated_object.get_account_option(AccountOption_TrustedForDelegation, g_adconfig);
QCOMPARE(updated_state, is_on);
}
QTEST_MAIN(ADMCTestDelegationEdit)
| 3,113
|
C++
|
.cpp
| 84
| 32.654762
| 113
| 0.703827
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,566
|
admc_test_group_type_edit.cpp
|
altlinux_admc/tests/admc_test_group_type_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_group_type_edit.h"
#include "attribute_edits/group_type_edit.h"
#include <QComboBox>
#include <QFormLayout>
void ADMCTestGroupTypeEdit::init() {
ADMCTest::init();
combo = new QComboBox(parent_widget);
edit = new GroupTypeEdit(combo, parent_widget);
const QString name = TEST_GROUP;
dn = test_object_dn(name, CLASS_GROUP);
const bool create_success = ad.object_add(dn, CLASS_GROUP);
QVERIFY(create_success);
}
void ADMCTestGroupTypeEdit::edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
combo->setCurrentIndex(1);
QVERIFY(edited_signal_emitted);
}
void ADMCTestGroupTypeEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QCOMPARE(combo->currentIndex(), 0);
}
void ADMCTestGroupTypeEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestGroupTypeEdit::apply() {
load();
combo->setCurrentIndex(1);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject updated_object = ad.search_object(dn);
const GroupType type = updated_object.get_group_type();
QCOMPARE(type, GroupType_Distribution);
}
QTEST_MAIN(ADMCTestGroupTypeEdit)
| 2,167
|
C++
|
.cpp
| 61
| 31.803279
| 72
| 0.722967
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,567
|
admc_test_string_edit.cpp
|
altlinux_admc/tests/admc_test_string_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_string_edit.h"
#include "attribute_edits/string_edit.h"
#include <QFormLayout>
#include <QLineEdit>
#define TEST_ATTRIBUTE ATTRIBUTE_FIRST_NAME
void ADMCTestStringEdit::init() {
ADMCTest::init();
line_edit = new QLineEdit(parent_widget);
edit = new StringEdit(line_edit, TEST_ATTRIBUTE, parent_widget);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
// edited() signal should be emitted when lineedit is edited
void ADMCTestStringEdit::test_emit_edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
line_edit->setText("test");
QVERIFY(edited_signal_emitted);
}
// Edit should contain current attribute value after load()
// call
void ADMCTestStringEdit::load() {
const QString test_value = "test value";
// Set attribute value
ad.attribute_replace_string(dn, TEST_ATTRIBUTE, test_value);
// Load user into edit
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const QString edit_value = line_edit->text();
;
QCOMPARE(edit_value, test_value);
}
void ADMCTestStringEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
// Edit should do change attribute to value
void ADMCTestStringEdit::apply_modified() {
const QString new_value = "new value";
line_edit->setText(new_value);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object = ad.search_object(dn);
const QString current_value = object.get_string(TEST_ATTRIBUTE);
QCOMPARE(current_value, new_value);
}
// Apply should trim leading and trailing spaces
void ADMCTestStringEdit::apply_trim() {
const QString new_value = " new value ";
line_edit->setText(new_value);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object = ad.search_object(dn);
const QString current_value = object.get_string(TEST_ATTRIBUTE);
QCOMPARE(current_value, new_value.trimmed());
}
QTEST_MAIN(ADMCTestStringEdit)
| 3,097
|
C++
|
.cpp
| 83
| 33.554217
| 72
| 0.722166
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,568
|
admc_test_ad_interface.cpp
|
altlinux_admc/tests/admc_test_ad_interface.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_ad_interface.h"
#include "globals.h"
#include "samba/dom_sid.h"
#include <QTest>
#define TEST_GPO "ADMCTestAdInterface_TEST_GPO"
void ADMCTestAdInterface::cleanup() {
// Delete test gpo, if it was leftover from previous test
const QString base = g_adconfig->domain_dn();
const QString filter = filter_CONDITION(Condition_Equals, ATTRIBUTE_DISPLAY_NAME, TEST_GPO);
const QList<QString> attributes = QList<QString>();
const QHash<QString, AdObject> search_results = ad.search(base, SearchScope_All, filter, attributes);
if (!search_results.isEmpty()) {
const QString dn = search_results.keys()[0];
bool deleted_object;
ad.gpo_delete(dn, &deleted_object);
}
ADMCTest::cleanup();
}
void ADMCTestAdInterface::create_and_gpo_delete() {
// Create new gpo
QString gpo_dn;
const bool create_success = ad.gpo_add(TEST_GPO, gpo_dn);
QVERIFY(create_success);
QVERIFY(!gpo_dn.isEmpty());
// Check perms
bool gpo_check_perms_ok = true;
const bool perms_are_ok = ad.gpo_check_perms(gpo_dn, &gpo_check_perms_ok);
QVERIFY(gpo_check_perms_ok);
QVERIFY(perms_are_ok);
// Create test ou
const QString ou_dn = test_object_dn(TEST_OU, CLASS_OU);
ad.object_add(ou_dn, CLASS_OU);
// Link gpo to ou
{
const AdObject ou_object = ad.search_object(ou_dn);
Gplink gplink = Gplink(ou_object.get_string(ATTRIBUTE_GPLINK));
gplink.add(gpo_dn);
ad.attribute_replace_string(ou_dn, ATTRIBUTE_GPLINK, gplink.to_string());
}
auto ou_is_linked_to_gpo = [&]() {
const AdObject ou_object = ad.search_object(ou_dn);
Gplink gplink = Gplink(ou_object.get_string(ATTRIBUTE_GPLINK));
const bool out = gplink.contains(gpo_dn);
return out;
};
const bool linked_before = ou_is_linked_to_gpo();
QCOMPARE(linked_before, true);
// Delete again;
bool deleted_object;
const bool delete_created_success = ad.gpo_delete(gpo_dn, &deleted_object);
QVERIFY(delete_created_success);
const bool linked_after = ou_is_linked_to_gpo();
QCOMPARE(linked_after, false);
}
void ADMCTestAdInterface::gpo_check_perms() {
QString gpc_dn;
const bool create_success = ad.gpo_add(TEST_GPO, gpc_dn);
QVERIFY(create_success);
QVERIFY(!gpc_dn.isEmpty());
bool gpo_check_perms_ok_1 = true;
const bool perms_before = ad.gpo_check_perms(gpc_dn, &gpo_check_perms_ok_1);
QVERIFY(gpo_check_perms_ok_1);
QCOMPARE(perms_before, true);
// Change GPC perms so they don't match with GPT perms
{
security_descriptor *new_sd = [&]() {
const AdObject gpc_object = ad.search_object(gpc_dn);
security_descriptor *out = gpc_object.get_security_descriptor();
// NOTE: S-1-1-0 is "WORLD"
const QByteArray trustee_everyone = sid_string_to_bytes("S-1-1-0");
const QList<QString> class_list = gpc_object.get_strings(ATTRIBUTE_OBJECT_CLASS);
security_descriptor_add_right(out, ad.adconfig(), class_list, trustee_everyone, SEC_ADS_GENERIC_ALL, QByteArray(), true);
return out;
}();
ad_security_replace_security_descriptor(ad, gpc_dn, new_sd);
}
bool gpo_check_perms_ok_2 = true;
const bool perms_after = ad.gpo_check_perms(gpc_dn, &gpo_check_perms_ok_2);
QVERIFY(gpo_check_perms_ok_2);
QCOMPARE(perms_after, false);
bool deleted_object;
const bool delete_success = ad.gpo_delete(gpc_dn, &deleted_object);
QVERIFY(delete_success);
}
void ADMCTestAdInterface::object_add() {
const QString dn = test_object_dn(TEST_USER, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY2(create_success, "Failed to create object");
QVERIFY2(object_exists(dn), "Created object doesn't exist");
}
void ADMCTestAdInterface::object_delete() {
const QString dn = test_object_dn(TEST_USER, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY2(create_success, "Failed to create object for deletion");
const bool delete_success = ad.object_delete(dn);
QVERIFY2(delete_success, "Failed to delete object");
QVERIFY2(!object_exists(dn), "Deleted object exists");
}
void ADMCTestAdInterface::object_move() {
const QString user_dn = test_object_dn(TEST_USER, CLASS_USER);
const bool add_user_success = ad.object_add(user_dn, CLASS_USER);
QVERIFY(add_user_success);
const QString ou_dn = test_object_dn(TEST_OU, CLASS_OU);
const bool add_ou_success = ad.object_add(ou_dn, CLASS_OU);
QVERIFY(add_ou_success);
const bool move_success = ad.object_move(user_dn, ou_dn);
QVERIFY(move_success);
const QString user_dn_after_move = dn_move(user_dn, ou_dn);
QVERIFY(object_exists(user_dn_after_move));
}
void ADMCTestAdInterface::object_rename() {
const QString user_dn = test_object_dn(TEST_USER, CLASS_USER);
const bool add_user_success = ad.object_add(user_dn, CLASS_USER);
QVERIFY(add_user_success);
const QString new_name = "new-name";
const bool rename_success = ad.object_rename(user_dn, new_name);
QVERIFY(rename_success);
const QString new_dn = test_object_dn(new_name, CLASS_USER);
QVERIFY(object_exists(new_dn));
}
void ADMCTestAdInterface::group_add_member() {
const QString user_dn = test_object_dn(TEST_USER, CLASS_USER);
const bool add_user_success = ad.object_add(user_dn, CLASS_USER);
QVERIFY(add_user_success);
const QString group_dn = test_object_dn(TEST_GROUP, CLASS_GROUP);
const bool add_group_success = ad.object_add(group_dn, CLASS_GROUP);
QVERIFY(add_group_success);
const bool add_member_success = ad.group_add_member(group_dn, user_dn);
QVERIFY(add_member_success);
const AdObject group_object = ad.search_object(group_dn);
const QList<QString> member_list = group_object.get_strings(ATTRIBUTE_MEMBER);
QCOMPARE(member_list, QList<QString>({user_dn}));
}
void ADMCTestAdInterface::group_remove_member() {
group_add_member();
const QString user_dn = test_object_dn(TEST_USER, CLASS_USER);
const QString group_dn = test_object_dn(TEST_GROUP, CLASS_GROUP);
const bool remove_member_success = ad.group_remove_member(group_dn, user_dn);
QVERIFY(remove_member_success);
const AdObject group_object = ad.search_object(group_dn);
const QList<QString> member_list = group_object.get_strings(ATTRIBUTE_MEMBER);
QVERIFY(member_list.isEmpty());
}
void ADMCTestAdInterface::group_set_scope() {
const QString group_dn = test_object_dn(TEST_GROUP, CLASS_GROUP);
const bool add_group_success = ad.object_add(group_dn, CLASS_GROUP);
QVERIFY(add_group_success);
for (int scope_i = 0; scope_i < GroupScope_COUNT; scope_i++) {
const GroupScope scope = (GroupScope) scope_i;
const bool success = ad.group_set_scope(group_dn, scope);
QVERIFY(success);
const AdObject group_object = ad.search_object(group_dn);
const GroupScope current_scope = group_object.get_group_scope();
QCOMPARE(current_scope, scope);
}
}
void ADMCTestAdInterface::group_set_type() {
const QString group_dn = test_object_dn(TEST_GROUP, CLASS_GROUP);
const bool add_group_success = ad.object_add(group_dn, CLASS_GROUP);
QVERIFY(add_group_success);
for (int type_i = 0; type_i < GroupType_COUNT; type_i++) {
const GroupType type = (GroupType) type_i;
const bool success = ad.group_set_type(group_dn, type);
QVERIFY(success);
const AdObject group_object = ad.search_object(group_dn);
const GroupType current_type = group_object.get_group_type();
QCOMPARE(current_type, type);
}
}
void ADMCTestAdInterface::user_set_account_option() {
const QString user_dn = test_object_dn(TEST_USER, CLASS_USER);
const bool add_user_success = ad.object_add(user_dn, CLASS_USER);
QVERIFY(add_user_success);
for (int option_i = 0; option_i < AccountOption_COUNT; option_i++) {
const AccountOption option = (AccountOption) option_i;
const bool success = ad.user_set_account_option(user_dn, option, true);
QVERIFY(success);
const AdObject object = ad.search_object(user_dn);
const bool option_set = object.get_account_option(option, g_adconfig);
QVERIFY(option_set);
}
}
QTEST_MAIN(ADMCTestAdInterface)
| 9,221
|
C++
|
.cpp
| 202
| 40.331683
| 133
| 0.696016
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,569
|
admc_test_manager_edit.cpp
|
altlinux_admc/tests/admc_test_manager_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_manager_edit.h"
#include "attribute_edits/manager_edit.h"
#include "attribute_edits/manager_widget.h"
#include "attribute_edits/ui_manager_widget.h"
#include "globals.h"
#include "properties_widgets/properties_dialog.h"
#include <QLineEdit>
#include <QPushButton>
void ADMCTestManagerEdit::init() {
ADMCTest::init();
auto manager_widget = new ManagerWidget(parent_widget);
edit = new ManagerEdit(manager_widget, ATTRIBUTE_MANAGER, parent_widget);
manager_display = manager_widget->ui->manager_display;
change_button = manager_widget->ui->change_button;
clear_button = manager_widget->ui->clear_button;
properties_button = manager_widget->ui->properties_button;
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
const QString manager_name = QString("%1%2").arg(TEST_USER, "-manager");
manager_dn = test_object_dn(manager_name, CLASS_USER);
const bool create_manager_success = ad.object_add(manager_dn, CLASS_USER);
QVERIFY(create_manager_success);
}
void ADMCTestManagerEdit::load_empty() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QVERIFY(manager_display->text().isEmpty());
}
void ADMCTestManagerEdit::load() {
const bool replace_success = ad.attribute_replace_string(dn, ATTRIBUTE_MANAGER, manager_dn);
QVERIFY(replace_success);
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const QString actual_value = manager_display->text();
const QString expected_value = dn_get_name(manager_dn);
QCOMPARE(actual_value, expected_value);
}
void ADMCTestManagerEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestManagerEdit::apply_after_change() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
change_button->click();
select_object_dialog_select(manager_dn);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject updated_object = ad.search_object(dn);
const QString updated_manager = updated_object.get_string(ATTRIBUTE_MANAGER);
QCOMPARE(updated_manager, manager_dn);
}
void ADMCTestManagerEdit::apply_after_clear() {
load();
clear_button->click();
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject updated_object = ad.search_object(dn);
const QString updated_manager = updated_object.get_string(ATTRIBUTE_MANAGER);
QVERIFY(updated_manager.isEmpty());
}
void ADMCTestManagerEdit::properties() {
load();
properties_button->click();
const bool properties_open = []() {
const QWidgetList widget_list = QApplication::topLevelWidgets();
for (QWidget *widget : widget_list) {
auto properties_dialog = qobject_cast<PropertiesDialog *>(widget);
if (properties_dialog != nullptr) {
return true;
}
}
return false;
}();
QVERIFY(properties_open);
}
QTEST_MAIN(ADMCTestManagerEdit)
| 3,935
|
C++
|
.cpp
| 97
| 36.268041
| 96
| 0.720851
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,570
|
admc_test_filter_widget.cpp
|
altlinux_admc/tests/admc_test_filter_widget.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_filter_widget.h"
#include "filter_widget/class_filter_widget.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/filter_widget_advanced_tab.h"
#include "filter_widget/filter_widget_normal_tab.h"
#include "filter_widget/filter_widget_simple_tab.h"
#include "filter_widget/select_classes_widget.h"
#include "filter_widget/ui_filter_widget.h"
#include "filter_widget/ui_filter_widget_advanced_tab.h"
#include "filter_widget/ui_filter_widget_normal_tab.h"
#include "filter_widget/ui_filter_widget_simple_tab.h"
#include "filter_widget/ui_select_classes_widget.h"
#include <QCheckBox>
#include <QDialog>
#include <QLineEdit>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QTabWidget>
#include <QVBoxLayout>
void ADMCTestFilterWidget::init() {
ADMCTest::init();
filter_widget = new FilterWidget();
filter_widget->set_classes(filter_classes, filter_classes);
add_widget(filter_widget);
tab_widget = filter_widget->ui->tab_widget;
simple_tab = filter_widget->ui->simple_tab;
normal_tab = filter_widget->ui->normal_tab;
advanced_tab = filter_widget->ui->advanced_tab;
}
void ADMCTestFilterWidget::test_simple_tab() {
tab_widget->setCurrentWidget(simple_tab);
SelectClassesWidget *select_classes_widget = simple_tab->ui->select_classes_widget;
QPushButton *select_button = select_classes_widget->ui->select_button;
select_button->click();
auto class_filter_dialog = select_classes_widget->findChild<QDialog *>();
QVERIFY(class_filter_dialog);
QVERIFY(QTest::qWaitForWindowExposed(class_filter_dialog, 1000));
const QList<QCheckBox *> checkbox_list = class_filter_dialog->findChildren<QCheckBox *>();
QVERIFY(!checkbox_list.isEmpty());
for (QCheckBox *checkbox : checkbox_list) {
const bool checked = (checkbox->text() == "User");
checkbox->setChecked(checked);
}
class_filter_dialog->accept();
QLineEdit *name_edit = simple_tab->ui->name_edit;
name_edit->setText("test");
const QString correct_filter = "(&(name=*test*)(objectClass=user))";
const QString filter = filter_widget->get_filter();
QCOMPARE(correct_filter, filter);
// Serialize
const QVariant state = filter_widget->save_state();
// Change state
name_edit->setText("changed");
// Deserialize
filter_widget->restore_state(state);
const QString filter_deserialized = filter_widget->get_filter();
QCOMPARE(correct_filter, filter_deserialized);
}
void ADMCTestFilterWidget::test_normal_tab() {
tab_widget->setCurrentWidget(normal_tab);
SelectClassesWidget *select_classes_widget = normal_tab->ui->select_classes_widget;
QPushButton *select_button = select_classes_widget->ui->select_button;
select_button->click();
auto class_filter_dialog = select_classes_widget->findChild<QDialog *>();
QVERIFY(class_filter_dialog);
QVERIFY(QTest::qWaitForWindowExposed(class_filter_dialog, 1000));
const QList<QCheckBox *> checkbox_list = class_filter_dialog->findChildren<QCheckBox *>();
QVERIFY(!checkbox_list.isEmpty());
for (QCheckBox *checkbox : checkbox_list) {
const bool checked = (checkbox->text() == "User");
checkbox->setChecked(checked);
}
class_filter_dialog->accept();
QLineEdit *value_edit = normal_tab->ui->value_edit;
value_edit->setText("value");
QPushButton *add_button = normal_tab->ui->add_button;
add_button->click();
const QString correct_filter = "(&(objectClass=user)(assistant=value))";
const QString filter = filter_widget->get_filter();
QCOMPARE(correct_filter, filter);
// Serialize
const QVariant state = filter_widget->save_state();
// Change state
value_edit->setText("value 2");
add_button->click();
// Deserialize
filter_widget->restore_state(state);
const QString filter_deserialized = filter_widget->get_filter();
QCOMPARE(correct_filter, filter_deserialized);
}
void ADMCTestFilterWidget::test_advanced_tab() {
tab_widget->setCurrentWidget(advanced_tab);
QPlainTextEdit *edit = advanced_tab->ui->ldap_filter_edit;
edit->setPlainText("test");
const QString correct_filter = "test";
const QString filter = filter_widget->get_filter();
QCOMPARE(correct_filter, filter);
// Serialize
const QVariant state = filter_widget->save_state();
// Change state
edit->setPlainText("changed");
// Deserialize
filter_widget->restore_state(state);
const QString filter_deserialized = filter_widget->get_filter();
QCOMPARE(correct_filter, filter_deserialized);
}
QTEST_MAIN(ADMCTestFilterWidget)
| 5,446
|
C++
|
.cpp
| 126
| 39.111111
| 94
| 0.728306
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,571
|
admc_test_find_policy_dialog.cpp
|
altlinux_admc/tests/admc_test_find_policy_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_find_policy_dialog.h"
#include "find_widgets/find_policy_dialog.h"
#include "find_widgets/find_policy_dialog_p.h"
#include "ui_find_policy_dialog.h"
#include <QComboBox>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
void ADMCTestFindPolicyDialog::init() {
ADMCTest::init();
ConsoleWidget *console = new ConsoleWidget(parent_widget);
dialog = new FindPolicyDialog(console, parent_widget);
}
void ADMCTestFindPolicyDialog::add_filter_data() {
QTest::addColumn<int>("search_item");
QTest::addColumn<int>("condition");
QTest::addColumn<QString>("value");
QTest::addColumn<QString>("expected_filter_display");
QTest::addColumn<QString>("expected_filter");
// clang-format off
QTest::newRow("1") << (int) SearchItem_Name << (int) Condition_Contains << "test" << "Name Contains: \"test\"" << "(displayName=*test*)";
QTest::newRow("2") << (int) SearchItem_GUID << (int) Condition_Contains << "test2" << "GUID Contains: \"test2\"" << "(cn=*test2*)";
QTest::newRow("3") << (int) SearchItem_GUID << (int) Condition_Equals << "{guid}" << "GUID Is (exactly): \"{guid}\"" << "(cn={guid})";
// clang-format on
}
void ADMCTestFindPolicyDialog::add_filter() {
QFETCH(int, search_item);
QFETCH(int, condition);
QFETCH(QString, value);
QFETCH(QString, expected_filter_display);
QFETCH(QString, expected_filter);
QComboBox *search_item_combo = dialog->ui->search_item_combo;
QComboBox *condition_combo = dialog->ui->condition_combo;
QLineEdit *value_edit = dialog->ui->value_edit;
QPushButton *add_button = dialog->ui->add_button;
QListWidget *filter_list = dialog->ui->filter_list;
search_item_combo->setCurrentIndex(search_item);
const int condition_index = [&]() {
for (int i = 0; i < condition_combo->count(); i++) {
const int data = condition_combo->itemData(i, Qt::UserRole).toInt();
if (data == condition) {
return i;
}
}
return -1;
}();
condition_combo->setCurrentIndex(condition_index);
value_edit->setText(value);
add_button->click();
QCOMPARE(filter_list->count(), 1);
QListWidgetItem *filter_item = filter_list->item(0);
const QString filter_display = filter_item->text();
QCOMPARE(filter_display, expected_filter_display);
const QString filter = filter_item->data(Qt::UserRole).toString();
QCOMPARE(filter, expected_filter);
}
QTEST_MAIN(ADMCTestFindPolicyDialog)
| 3,309
|
C++
|
.cpp
| 76
| 39.184211
| 141
| 0.691781
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,572
|
admc_test_country_edit.cpp
|
altlinux_admc/tests/admc_test_country_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_country_edit.h"
#include "attribute_edits/country_combo.h"
#include "attribute_edits/country_edit.h"
#include <QComboBox>
#include <QFormLayout>
#define TEST_ATTRIBUTE ATTRIBUTE_FIRST_NAME
void ADMCTestCountryEdit::init() {
ADMCTest::init();
country_combo_load_data();
combo = new QComboBox(parent_widget);
edit = new CountryEdit(combo, parent_widget);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
// Combo count should be some decently large number. If csv
// failed to load, combo would have just the "None" item
void ADMCTestCountryEdit::loaded_csv_file() {
QVERIFY(combo->count() > 200);
}
// edited() signal should be emitted when lineedit is edited
void ADMCTestCountryEdit::emit_edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
combo->setCurrentIndex(combo->currentIndex() + 1);
QVERIFY(edited_signal_emitted);
}
// Edit should contain current attribute value after load()
// call
void ADMCTestCountryEdit::load() {
// Set attribute value
const int test_value = 4;
ad.attribute_replace_int(dn, ATTRIBUTE_COUNTRY_CODE, test_value);
// Load user into edit
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const int edit_value = combo->currentData().toInt();
QCOMPARE(edit_value, test_value);
}
void ADMCTestCountryEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
// Edit should do change attribute to value.
void ADMCTestCountryEdit::apply_modified() {
const int new_value = 8;
const int new_value_index = combo->findData(QVariant(new_value));
combo->setCurrentIndex(new_value_index);
const AdObject object_before = ad.search_object(dn);
const QString country_abbreviation_before = object_before.get_string(ATTRIBUTE_COUNTRY_ABBREVIATION);
const QString country_before = object_before.get_string(ATTRIBUTE_COUNTRY);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object_after = ad.search_object(dn);
const int current_value = object_after.get_int(ATTRIBUTE_COUNTRY_CODE);
const QString country_abbreviation_after = object_after.get_string(ATTRIBUTE_COUNTRY_ABBREVIATION);
const QString country_after = object_after.get_string(ATTRIBUTE_COUNTRY);
QCOMPARE(current_value, new_value);
// NOTE: figuring out what abbreviation and country
// strings are actually supposed to be requires parsing
// the countries csv file, so just check that these
// strings changed.
QVERIFY(country_abbreviation_after != country_abbreviation_before);
QVERIFY(country_after != country_before);
}
QTEST_MAIN(ADMCTestCountryEdit)
| 3,763
|
C++
|
.cpp
| 91
| 37.582418
| 105
| 0.734795
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,573
|
admc_test_protect_deletion_edit.cpp
|
altlinux_admc/tests/admc_test_protect_deletion_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_protect_deletion_edit.h"
#include "attribute_edits/protect_deletion_edit.h"
#include <QCheckBox>
void ADMCTestProtectDeletionEdit::init() {
ADMCTest::init();
checkbox = new QCheckBox(parent_widget);
edit = new ProtectDeletionEdit(checkbox, parent_widget);
dn = test_object_dn(TEST_OU, CLASS_OU);
const bool create_success = ad.object_add(dn, CLASS_OU);
QVERIFY(create_success);
}
void ADMCTestProtectDeletionEdit::edited_signal_data() {
QTest::addColumn<bool>("start_state");
QTest::newRow("when checked") << false;
QTest::newRow("when unchecked") << true;
}
void ADMCTestProtectDeletionEdit::edited_signal() {
QFETCH(bool, start_state);
const bool end_state = !start_state;
checkbox->setChecked(start_state);
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
checkbox->setChecked(end_state);
QVERIFY(edited_signal_emitted);
}
void ADMCTestProtectDeletionEdit::apply_data() {
QTest::addColumn<bool>("is_checked");
QTest::addColumn<bool>("expected_delete_success");
QTest::newRow("protected") << true << false;
QTest::newRow("not protected") << false << true;
}
void ADMCTestProtectDeletionEdit::apply() {
QFETCH(bool, is_checked);
QFETCH(bool, expected_delete_success);
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
checkbox->setChecked(is_checked);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
qInfo() << "Error relating to \"Insufficient access\" is part of the test";
const bool actual_delete_success = ad.object_delete(dn);
QCOMPARE(actual_delete_success, expected_delete_success);
// Finally, disable protection so test suite can
// delete this object to clean up
if (!actual_delete_success) {
checkbox->setChecked(false);
const bool apply_2_success = edit->apply(ad, dn);
QVERIFY(apply_2_success);
}
}
QTEST_MAIN(ADMCTestProtectDeletionEdit)
| 2,912
|
C++
|
.cpp
| 75
| 34.586667
| 79
| 0.712358
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,574
|
admc_test_datetime_attribute_dialog.cpp
|
altlinux_admc/tests/admc_test_datetime_attribute_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_datetime_attribute_dialog.h"
#include "attribute_dialogs/datetime_attribute_dialog.h"
#include "attribute_dialogs/ui_datetime_attribute_dialog.h"
#include <QDateTimeEdit>
void ADMCTestDatetimeAttributeDialog::initTestCase_data() {
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::addColumn<QDateTime>("display_value");
QTest::newRow("non-empty") << QList<QByteArray>({"20210706131457.0Z"}) << QDateTime(QDate(2021, 7, 6), QTime(13, 14, 57));
}
void ADMCTestDatetimeAttributeDialog::init() {
ADMCTest::init();
QFETCH_GLOBAL(QList<QByteArray>, value_list);
dialog = new DatetimeAttributeDialog(value_list, ATTRIBUTE_WHEN_CHANGED, false, parent_widget);
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
datetime_edit = dialog->ui->edit;
}
void ADMCTestDatetimeAttributeDialog::display_value() {
QFETCH_GLOBAL(QDateTime, display_value);
const QDateTime actual_display_value = datetime_edit->dateTime();
QCOMPARE(actual_display_value, display_value);
}
void ADMCTestDatetimeAttributeDialog::get_value_list() {
QFETCH_GLOBAL(QList<QByteArray>, value_list);
const QList<QByteArray> actualy_value_list = dialog->get_value_list();
QCOMPARE(actualy_value_list, value_list);
}
QTEST_MAIN(ADMCTestDatetimeAttributeDialog)
| 2,107
|
C++
|
.cpp
| 47
| 41.87234
| 126
| 0.758065
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,575
|
admc_test_octet_attribute_dialog.cpp
|
altlinux_admc/tests/admc_test_octet_attribute_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_octet_attribute_dialog.h"
#include "attribute_dialogs/octet_attribute_dialog.h"
#include "attribute_dialogs/ui_octet_attribute_dialog.h"
#include <QComboBox>
#include <QPlainTextEdit>
void ADMCTestOctetAttributeDialog::initTestCase_data() {
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::addColumn<int>("index");
QTest::addColumn<int>("other_index");
QTest::addColumn<QString>("display_value");
const QList<QByteArray> test_value_list = {QByteArray("12345")};
QTest::newRow("hex") << test_value_list << 0 << 1 << "31 32 33 34 35";
QTest::newRow("bin") << test_value_list << 1 << 2 << "00110001 00110010 00110011 00110100 00110101";
QTest::newRow("dec") << test_value_list << 2 << 3 << "049 050 051 052 053";
QTest::newRow("oct") << test_value_list << 3 << 0 << "061 062 063 064 065";
QTest::newRow("empty") << QList<QByteArray>() << 0 << 1 << "";
;
}
void ADMCTestOctetAttributeDialog::init() {
ADMCTest::init();
QFETCH_GLOBAL(QList<QByteArray>, value_list);
dialog = new OctetAttributeDialog(value_list, ATTRIBUTE_DESCRIPTION, false, parent_widget);
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
format_combo = dialog->ui->format_combo;
text_edit = dialog->ui->edit;
}
void ADMCTestOctetAttributeDialog::display_value() {
QFETCH_GLOBAL(QString, display_value);
QFETCH_GLOBAL(int, index);
format_combo->setCurrentIndex(index);
const QString actual_display_value = text_edit->toPlainText();
QCOMPARE(actual_display_value, display_value);
}
// Check that edit correctly converts formatted strings back
// to bytes for each format
void ADMCTestOctetAttributeDialog::get_value_list() {
QFETCH_GLOBAL(QList<QByteArray>, value_list);
const QList<QByteArray> actual_value_list = dialog->get_value_list();
QCOMPARE(actual_value_list, value_list);
}
// Check that when incorrectly formatted value is entered,
// edit fails to switch to different format
void ADMCTestOctetAttributeDialog::handle_incorrect_input() {
QFETCH_GLOBAL(int, index);
QFETCH_GLOBAL(int, other_index);
format_combo->setCurrentIndex(index);
text_edit->setPlainText("incorrect format");
format_combo->setCurrentIndex(other_index);
close_message_box();
QCOMPARE(format_combo->currentIndex(), index);
}
QTEST_MAIN(ADMCTestOctetAttributeDialog)
| 3,184
|
C++
|
.cpp
| 72
| 40.861111
| 104
| 0.729301
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,576
|
admc_test_datetime_edit.cpp
|
altlinux_admc/tests/admc_test_datetime_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_datetime_edit.h"
#include "attribute_edits/datetime_edit.h"
#include "globals.h"
#include <QDateTimeEdit>
// NOTE: no apply_unmodified() test because all datetime
// attributes are read-only
void ADMCTestDateTimeEdit::init() {
ADMCTest::init();
qedit = new QDateTimeEdit(parent_widget);
edit = new DateTimeEdit(qedit, ATTRIBUTE_WHEN_CHANGED, parent_widget);
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
void ADMCTestDateTimeEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const QDateTime correct_datetime = object.get_datetime(ATTRIBUTE_WHEN_CHANGED, g_adconfig);
const QDateTime datetime = qedit->dateTime();
QCOMPARE(datetime, correct_datetime);
}
QTEST_MAIN(ADMCTestDateTimeEdit)
| 1,686
|
C++
|
.cpp
| 42
| 37.285714
| 95
| 0.749387
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,577
|
admc_test_string_other_edit.cpp
|
altlinux_admc/tests/admc_test_string_other_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_string_other_edit.h"
#include "attribute_dialogs/list_attribute_dialog.h"
#include "attribute_dialogs/string_attribute_dialog.h"
#include "attribute_dialogs/ui_list_attribute_dialog.h"
#include "attribute_edits/string_other_edit.h"
#include <QFormLayout>
#include <QLineEdit>
#include <QListWidget>
#include <QPlainTextEdit>
#include <QPushButton>
#define TEST_ATTRIBUTE_MAIN ATTRIBUTE_WWW_HOMEPAGE
#define TEST_ATTRIBUTE_OTHER ATTRIBUTE_WWW_HOMEPAGE_OTHER
const QString main_value = "main_value";
const QList<QByteArray> other_value_list = {
"first",
"second",
"third",
};
#define new_value "new_value"
void ADMCTestStringOtherEdit::init() {
ADMCTest::init();
line_edit = new QLineEdit(parent_widget);
other_button = new QPushButton(parent_widget);
edit = new StringOtherEdit(line_edit, other_button, TEST_ATTRIBUTE_MAIN, ATTRIBUTE_WWW_HOMEPAGE_OTHER, parent_widget);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
// Set values
ad.attribute_replace_string(dn, TEST_ATTRIBUTE_MAIN, main_value);
ad.attribute_replace_values(dn, TEST_ATTRIBUTE_OTHER, other_value_list);
// Load user into edit
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
}
// edited() signal should be emitted when lineedit is edited
// and when other values are added
void ADMCTestStringOtherEdit::test_emit_edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
line_edit->setText("test");
QVERIFY(edited_signal_emitted);
edited_signal_emitted = false;
add_new_other_value();
QVERIFY(edited_signal_emitted);
}
// Edit should contain current attribute value after load()
// call
void ADMCTestStringOtherEdit::load() {
QCOMPARE(line_edit->text(), main_value);
other_button->click();
auto list_attribute_dialog = parent_widget->findChild<ListAttributeDialog *>();
QVERIFY(list_attribute_dialog);
auto list_widget = list_attribute_dialog->findChild<QListWidget *>();
QVERIFY(list_widget);
QCOMPARE(line_edit->text(), main_value);
for (int i = 0; i < 3; i++) {
QCOMPARE(list_widget->item(i)->text(), other_value_list[i]);
}
}
void ADMCTestStringOtherEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestStringOtherEdit::apply_modified_main_value() {
line_edit->setText(new_value);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object = ad.search_object(dn);
const QString current_value_main = object.get_string(TEST_ATTRIBUTE_MAIN);
QCOMPARE(current_value_main, new_value);
const QList<QByteArray> current_value_other = object.get_values(TEST_ATTRIBUTE_OTHER);
QCOMPARE(current_value_other, other_value_list);
}
void ADMCTestStringOtherEdit::apply_modified_other_value() {
add_new_other_value();
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject object = ad.search_object(dn);
const QString current_value_main = object.get_string(TEST_ATTRIBUTE_MAIN);
QCOMPARE(current_value_main, main_value);
const QList<QByteArray> current_value_other = object.get_values(TEST_ATTRIBUTE_OTHER);
QList<QByteArray> correct_value_other = other_value_list;
correct_value_other.append(new_value);
QCOMPARE(current_value_other, correct_value_other);
}
void ADMCTestStringOtherEdit::add_new_other_value() {
other_button->click();
auto list_attribute_dialog = parent_widget->findChild<ListAttributeDialog *>();
QVERIFY(list_attribute_dialog);
QPushButton *add_button = list_attribute_dialog->ui->add_button;
add_button->click();
auto string_attribute_dialog = list_attribute_dialog->findChild<StringAttributeDialog *>();
QVERIFY(string_attribute_dialog);
auto string_attribute_dialog_line_edit = string_attribute_dialog->findChild<QPlainTextEdit *>();
QVERIFY(string_attribute_dialog_line_edit);
string_attribute_dialog_line_edit->setPlainText(new_value);
string_attribute_dialog->accept();
list_attribute_dialog->accept();
}
QTEST_MAIN(ADMCTestStringOtherEdit)
| 5,218
|
C++
|
.cpp
| 125
| 37.752
| 122
| 0.734403
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,578
|
admc_test_edit_query_item_widget.cpp
|
altlinux_admc/tests/admc_test_edit_query_item_widget.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_edit_query_item_widget.h"
#include "console_impls/query_item_impl.h"
#include "edit_query_widgets/edit_query_item_widget.h"
#include "filter_widget/filter_dialog.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/filter_widget_simple_tab.h"
#include "filter_widget/select_base_widget.h"
#include "filter_widget/ui_filter_widget.h"
#include "filter_widget/ui_filter_widget_simple_tab.h"
#include "filter_widget/ui_select_base_widget.h"
#include "tab_widget.h"
#include "ui_edit_query_item_widget.h"
#include "ui_filter_dialog.h"
#include <QCheckBox>
#include <QComboBox>
#include <QLineEdit>
#include <QPushButton>
#include <QStandardItem>
#include <QTextEdit>
void ADMCTestEditQueryItemWidget::init() {
ADMCTest::init();
widget = new EditQueryItemWidget();
add_widget(widget);
name_edit = widget->ui->name_edit;
description_edit = widget->ui->description_edit;
scope_checkbox = widget->ui->scope_checkbox;
SelectBaseWidget *select_base_widget = widget->ui->select_base_widget;
base_combo = select_base_widget->ui->combo;
edit_filter_button = widget->ui->edit_filter_button;
filter_display = widget->ui->filter_display;
}
void ADMCTestEditQueryItemWidget::save_and_load() {
// Define and set correct values
const QString correct_name = "name";
name_edit->setText(correct_name);
const QString correct_description = "description";
description_edit->setText(correct_description);
const bool correct_scope = true;
scope_checkbox->setChecked(correct_scope);
// NOTE: just using the default value for base correct
// value
const QString correct_base = base_combo->currentText();
QVERIFY(!correct_base.isEmpty());
// Set correct filter filter (a bit complicated!)
edit_filter_button->click();
FilterDialog *dialog = widget->findChild<FilterDialog *>();
QVERIFY(dialog);
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
FilterWidgetSimpleTab *simple_tab = dialog->ui->filter_widget->ui->simple_tab;
QLineEdit *filter_name_edit = simple_tab->ui->name_edit;
filter_name_edit->setText("test");
dialog->accept();
const QString correct_filter = filter_display->toPlainText();
const QList<QStandardItem *> row = [=]() {
QList<QStandardItem *> out;
for (int i = 0; i < QueryColumn_COUNT; i++) {
out.append(new QStandardItem());
}
return out;
}();
// NOTE: need to insert into model so that indexes are valid
auto model = new QStandardItemModel();
model->appendRow(row);
{
const QString name = widget->name();
const QString description = widget->description();
const QString filter = widget->filter();
const QString base = widget->base();
const QByteArray filter_state = widget->filter_state();
const bool scope_is_children = widget->scope_is_children();
console_query_item_load(row, name, description, filter, filter_state, base, scope_is_children);
}
const QModelIndex index = row[0]->index();
{
QString name;
QString description;
bool scope_is_children;
QByteArray filter_state;
QString filter;
get_query_item_data(index, &name, &description, &scope_is_children, &filter_state, &filter);
widget->set_data(name, description, scope_is_children, filter_state, filter);
}
QCOMPARE(name_edit->text(), correct_name);
QCOMPARE(description_edit->text(), correct_description);
QCOMPARE(scope_checkbox->isChecked(), correct_scope);
QCOMPARE(base_combo->currentText(), correct_base);
QCOMPARE(filter_display->toPlainText(), correct_filter);
}
QTEST_MAIN(ADMCTestEditQueryItemWidget)
| 4,544
|
C++
|
.cpp
| 108
| 37.472222
| 103
| 0.712826
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,579
|
admc_test_select_object_dialog.cpp
|
altlinux_admc/tests/admc_test_select_object_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_select_object_dialog.h"
#include "admc_test_select_base_widget.h"
#include "console_impls/object_impl.h"
#include "filter_widget/select_base_widget.h"
#include "select_dialogs/select_object_dialog.h"
#include "select_dialogs/select_object_match_dialog.h"
#include "ui_select_object_dialog.h"
#include "ui_select_object_match_dialog.h"
#include <QLineEdit>
#include <QPushButton>
#include <QTreeView>
void ADMCTestSelectObjectDialog::init() {
ADMCTest::init();
dialog = new SelectObjectDialog({CLASS_USER}, SelectObjectDialogMultiSelection_Yes, parent_widget);
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
SelectBaseWidget *select_base_widget = dialog->ui->select_base_widget;
select_base_widget_add(select_base_widget, test_arena_dn());
edit = dialog->ui->name_edit;
add_button = dialog->ui->add_button;
}
void ADMCTestSelectObjectDialog::empty() {
const QList<QString> selected = dialog->get_selected();
QVERIFY(selected.isEmpty());
}
void ADMCTestSelectObjectDialog::no_matches() {
const QString dn = test_object_dn(TEST_USER, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
edit->setText("no-match");
add_button->click();
close_message_box();
const QList<QString> selected = dialog->get_selected();
QVERIFY(selected.isEmpty());
}
void ADMCTestSelectObjectDialog::one_match() {
const QString dn = test_object_dn(TEST_USER, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
edit->setText(TEST_USER);
add_button->click();
const QList<QString> selected = dialog->get_selected();
QCOMPARE(selected.size(), 1);
if (selected.size() == 1) {
QCOMPARE(selected[0], dn);
}
}
void ADMCTestSelectObjectDialog::multiple_matches() {
const QString dn1 = test_object_dn(QString(TEST_USER) + "1", CLASS_USER);
const bool create_success1 = ad.object_add(dn1, CLASS_USER);
QVERIFY(create_success1);
const QString dn2 = test_object_dn(QString(TEST_USER) + "2", CLASS_USER);
const bool create_success2 = ad.object_add(dn2, CLASS_USER);
QVERIFY(create_success2);
select_object_in_multi_match_dialog(TEST_USER, dn2);
const QList<QString> selected = dialog->get_selected();
QCOMPARE(selected, QList<QString>({dn2}));
}
// Adding same object two times should open message box
// warning about duplicate and also not add it twice
void ADMCTestSelectObjectDialog::one_match_duplicate() {
const QString dn = test_object_dn(TEST_USER, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
edit->setText(TEST_USER);
add_button->click();
const QList<QString> selected_first = dialog->get_selected();
QCOMPARE(selected_first, QList<QString>({dn}));
edit->setText(TEST_USER);
add_button->click();
close_message_box();
const QList<QString> selected_second = dialog->get_selected();
QCOMPARE(selected_second, QList<QString>({dn}));
}
// Duplicates should also be processed for multiple match
// case
void ADMCTestSelectObjectDialog::multiple_match_duplicate() {
const QString dn1 = test_object_dn(QString(TEST_USER) + "1", CLASS_USER);
const bool create_success1 = ad.object_add(dn1, CLASS_USER);
QVERIFY(create_success1);
const QString dn2 = test_object_dn(QString(TEST_USER) + "2", CLASS_USER);
const bool create_success2 = ad.object_add(dn2, CLASS_USER);
QVERIFY(create_success2);
select_object_in_multi_match_dialog(TEST_USER, dn2);
const QList<QString> selected_first = dialog->get_selected();
QCOMPARE(selected_first, QList<QString>({dn2}));
select_object_in_multi_match_dialog(TEST_USER, dn2);
const QList<QString> selected_second = dialog->get_selected();
QCOMPARE(selected_second, QList<QString>({dn2}));
}
void ADMCTestSelectObjectDialog::select_object_in_multi_match_dialog(const QString &name, const QString &dn) {
edit->setText(name);
add_button->click();
auto match_dialog = dialog->findChild<SelectObjectMatchDialog *>();
QVERIFY(match_dialog);
QTreeView *match_dialog_view = match_dialog->ui->view;
wait_for_find_results_to_load(match_dialog_view);
navigate_until_object(match_dialog_view, dn, ObjectRole_DN);
match_dialog->accept();
close_message_box();
}
QTEST_MAIN(ADMCTestSelectObjectDialog)
| 5,262
|
C++
|
.cpp
| 121
| 39.644628
| 110
| 0.728574
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,580
|
admc_test_group_scope_edit.cpp
|
altlinux_admc/tests/admc_test_group_scope_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_group_scope_edit.h"
#include "attribute_edits/group_scope_edit.h"
#include <QComboBox>
#include <QFormLayout>
void ADMCTestGroupScopeEdit::init() {
ADMCTest::init();
combo = new QComboBox(parent_widget);
edit = new GroupScopeEdit(combo, parent_widget);
const QString name = TEST_GROUP;
dn = test_object_dn(name, CLASS_GROUP);
const bool create_success = ad.object_add(dn, CLASS_GROUP);
QVERIFY(create_success);
}
void ADMCTestGroupScopeEdit::edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
combo->setCurrentIndex(1);
QVERIFY(edited_signal_emitted);
}
void ADMCTestGroupScopeEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QCOMPARE(combo->currentIndex(), 0);
}
void ADMCTestGroupScopeEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestGroupScopeEdit::apply() {
load();
combo->setCurrentIndex(1);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject updated_object = ad.search_object(dn);
const GroupScope scope = updated_object.get_group_scope();
QCOMPARE(scope, GroupScope_DomainLocal);
}
QTEST_MAIN(ADMCTestGroupScopeEdit)
| 2,180
|
C++
|
.cpp
| 61
| 32.016393
| 72
| 0.724679
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,581
|
admc_test_ad_security.cpp
|
altlinux_admc/tests/admc_test_ad_security.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_ad_security.h"
#include "ad_security.h"
#include "samba/ndr_security.h"
// NOTE: using "int" instead of "uint32_t" for test
// data because "uint32_t" is not supported by
// QTest::addColumn()
void ADMCTestAdSecurity::initTestCase() {
// NOTE: important to set sd early here, because
// base class initTestCase() calls cleanup() which
// needs to not free sd
sd = NULL;
ADMCTest::initTestCase();
}
void ADMCTestAdSecurity::init() {
ADMCTest::init();
// Create test user
test_user_dn = test_object_dn(TEST_USER, CLASS_USER);
const bool create_test_user_success = ad.object_add(test_user_dn, CLASS_USER);
QVERIFY(create_test_user_success);
// Create test trustee (which is a user)
test_trustee_dn = test_object_dn("test-trustee", CLASS_USER);
const bool create_test_trustee_success = ad.object_add(test_trustee_dn, CLASS_USER);
QVERIFY(create_test_trustee_success);
test_trustee = [&]() {
const AdObject test_trustee_object = ad.search_object(test_user_dn);
const QByteArray out = test_trustee_object.get_value(ATTRIBUTE_OBJECT_SID);
return out;
}();
load_sd();
}
void ADMCTestAdSecurity::cleanup() {
ADMCTest::cleanup();
security_descriptor_free(sd);
sd = NULL;
}
void ADMCTestAdSecurity::add_right() {
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, SEC_ADS_CREATE_CHILD, QByteArray(), true);
check_state(test_trustee, SEC_ADS_CREATE_CHILD, QByteArray(), TestAdSecurityType_Allow);
}
void ADMCTestAdSecurity::remove_right() {
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, SEC_ADS_CREATE_CHILD, QByteArray(), true);
check_state(test_trustee, SEC_ADS_CREATE_CHILD, QByteArray(), TestAdSecurityType_Allow);
security_descriptor_remove_right(sd, ad.adconfig(), class_list, test_trustee, SEC_ADS_CREATE_CHILD, QByteArray(), true);
check_state(test_trustee, SEC_ADS_CREATE_CHILD, QByteArray(), TestAdSecurityType_None);
}
void ADMCTestAdSecurity::remove_trustee() {
const QList<uint32_t> mask_list = {
SEC_ADS_CREATE_CHILD,
SEC_STD_DELETE,
};
for (const uint32_t &mask : mask_list) {
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, mask, QByteArray(), true);
}
for (const uint32_t &mask : mask_list) {
check_state(test_trustee, mask, QByteArray(), TestAdSecurityType_Allow);
}
security_descriptor_remove_trustee(sd, {test_trustee});
for (const uint32_t &mask : mask_list) {
check_state(test_trustee, mask, QByteArray(), TestAdSecurityType_None);
}
}
// Removing generic read while full control is
// allowed, should leave generic write, even though
// they share a bit, and vice versa
void ADMCTestAdSecurity::handle_generic_read_and_write_sharing_bit() {
const QHash<uint32_t, uint32_t> opposite_map = {
{SEC_ADS_GENERIC_READ, SEC_ADS_GENERIC_WRITE},
{SEC_ADS_GENERIC_WRITE, SEC_ADS_GENERIC_READ},
};
for (const uint32_t &mask : opposite_map.keys()) {
const uint32_t opposite = opposite_map[mask];
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, mask, QByteArray(), true);
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, opposite, QByteArray(), true);
check_state(test_trustee, mask, QByteArray(), TestAdSecurityType_Allow);
check_state(test_trustee, opposite, QByteArray(), TestAdSecurityType_Allow);
security_descriptor_remove_right(sd, ad.adconfig(), class_list, test_trustee, mask, QByteArray(), true);
check_state(test_trustee, opposite, QByteArray(), TestAdSecurityType_Allow);
}
}
void ADMCTestAdSecurity::protected_against_deletion_data() {
QTest::addColumn<bool>("enabled");
QTest::addColumn<TestAdSecurityType>("correct_type");
QTest::newRow("enabled") << true << TestAdSecurityType_Deny;
QTest::newRow("disabled") << false << TestAdSecurityType_None;
}
void ADMCTestAdSecurity::protected_against_deletion() {
QFETCH(bool, enabled);
QFETCH(TestAdSecurityType, correct_type);
ad_security_set_protected_against_deletion(ad, test_user_dn, enabled);
// NOTE: need to reload sd since this modifies it
// on the server!
load_sd();
// Check state ourselves
const QByteArray trustee_everyone = sid_string_to_bytes(SID_WORLD);
const QList<uint32_t> protect_deletion_mask_list = {
SEC_STD_DELETE,
SEC_ADS_DELETE_TREE,
};
for (const uint32_t &mask : protect_deletion_mask_list) {
check_state(trustee_everyone, mask, QByteArray(), correct_type);
}
// Check using the getter
const AdObject object = ad.search_object(test_user_dn);
const bool actual_from_get = ad_security_get_protected_against_deletion(object);
QCOMPARE(actual_from_get, enabled);
}
void ADMCTestAdSecurity::cant_change_pass_data() {
QTest::addColumn<bool>("enabled");
QTest::addColumn<TestAdSecurityType>("correct_type");
QTest::newRow("enabled") << true << TestAdSecurityType_Deny;
QTest::newRow("disabled") << false << TestAdSecurityType_Allow;
}
void ADMCTestAdSecurity::cant_change_pass() {
QFETCH(bool, enabled);
QFETCH(TestAdSecurityType, correct_type);
ad_security_set_user_cant_change_pass(&ad, test_user_dn, enabled);
// NOTE: need to reload sd since this modifies it
// on the server!
load_sd();
// Check state ourselves
const QList<QString> cant_change_pass_trustee_cn_list = {
SID_NT_SELF,
SID_WORLD,
};
for (const QString &trustee_cn : cant_change_pass_trustee_cn_list) {
const QByteArray trustee = sid_string_to_bytes(trustee_cn);
const QByteArray change_pass_right = ad.adconfig()->get_right_guid("User-Change-Password");
check_state(trustee, SEC_ADS_CONTROL_ACCESS, change_pass_right, correct_type);
}
// Check using the getter
const AdObject object = ad.search_object(test_user_dn);
const bool actual_from_get = ad_security_get_user_cant_change_pass(&object, ad.adconfig());
QCOMPARE(actual_from_get, enabled);
}
// Setting a right should unset it's opposite. For
// example, set allow for X, then set deny for Y, allow
// for X should go away as a result.
void ADMCTestAdSecurity::add_to_unset_opposite_data() {
QTest::addColumn<bool>("first_allow");
QTest::addColumn<int>("access_mask");
QTest::addColumn<QByteArray>("object_type");
QTest::addColumn<TestAdSecurityType>("expected_result");
const QByteArray allowed_to_auth_object_type = ad.adconfig()->get_right_guid("Allowed-To-Authenticate");
QTest::newRow("allow [create child]") << true << SEC_ADS_CREATE_CHILD << QByteArray() << TestAdSecurityType_Deny;
QTest::newRow("deny [create child]") << false << SEC_ADS_CREATE_CHILD << QByteArray() << TestAdSecurityType_Allow;
QTest::newRow("allow [allowed to authenticate]") << true << SEC_ADS_CONTROL_ACCESS << allowed_to_auth_object_type << TestAdSecurityType_Deny;
QTest::newRow("deny [allowed to authenticate]") << false << SEC_ADS_CONTROL_ACCESS << allowed_to_auth_object_type << TestAdSecurityType_Allow;
}
void ADMCTestAdSecurity::add_to_unset_opposite() {
QFETCH(bool, first_allow);
QFETCH(int, access_mask);
QFETCH(QByteArray, object_type);
QFETCH(TestAdSecurityType, expected_result);
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, access_mask, object_type, first_allow);
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, access_mask, object_type, !first_allow);
check_state(test_trustee, access_mask, object_type, expected_result);
}
// When a right is unset, if it has any subordinates,
// they should become set. Logic here is that
// subordinates are "contained" by the superior's ACE
// but when superior is unset, they need their own
// ACE'S. For example, unsetting "generic read" should
// set all subordinate rights for reading properties.
void ADMCTestAdSecurity::remove_to_set_subordinates_data() {
QTest::addColumn<bool>("allow_superior");
QTest::addColumn<int>("superior_mask");
QTest::addColumn<QByteArray>("subordinate_right_type");
QTest::addColumn<QList<int>>("subordinate_mask_list");
QTest::addColumn<TestAdSecurityType>("exptected_state");
const QByteArray type_web_info = ad.adconfig()->get_right_guid("Web-Information");
const QByteArray type_change_password = ad.adconfig()->get_right_guid("User-Change-Password");
QTest::newRow("allow full control") << true << SEC_ADS_GENERIC_ALL << type_web_info << QList<int>({SEC_ADS_WRITE_PROP, SEC_ADS_READ_PROP}) << TestAdSecurityType_Allow;
QTest::newRow("deny full control") << false << SEC_ADS_GENERIC_ALL << type_web_info << QList<int>({SEC_ADS_WRITE_PROP, SEC_ADS_READ_PROP}) << TestAdSecurityType_Deny;
QTest::newRow("allow generic read") << true << SEC_ADS_GENERIC_READ << type_web_info << QList<int>({SEC_ADS_READ_PROP}) << TestAdSecurityType_Allow;
QTest::newRow("deny generic read") << false << SEC_ADS_GENERIC_READ << type_web_info << QList<int>({SEC_ADS_READ_PROP}) << TestAdSecurityType_Deny;
QTest::newRow("allow generic write") << true << SEC_ADS_GENERIC_WRITE << type_web_info << QList<int>({SEC_ADS_WRITE_PROP}) << TestAdSecurityType_Allow;
QTest::newRow("deny generic write") << false << SEC_ADS_GENERIC_WRITE << type_web_info << QList<int>({SEC_ADS_WRITE_PROP}) << TestAdSecurityType_Deny;
QTest::newRow("allow all extended rights") << true << SEC_ADS_CONTROL_ACCESS << type_change_password << QList<int>({SEC_ADS_CONTROL_ACCESS}) << TestAdSecurityType_Allow;
QTest::newRow("allow all extended rights") << true << SEC_ADS_CONTROL_ACCESS << type_change_password << QList<int>({SEC_ADS_CONTROL_ACCESS}) << TestAdSecurityType_Allow;
QTest::newRow("deny all extended rights") << false << SEC_ADS_CONTROL_ACCESS << type_change_password << QList<int>({SEC_ADS_CONTROL_ACCESS}) << TestAdSecurityType_Deny;
}
void ADMCTestAdSecurity::remove_to_set_subordinates() {
QFETCH(bool, allow_superior);
QFETCH(int, superior_mask);
QFETCH(QByteArray, subordinate_right_type);
QFETCH(QList<int>, subordinate_mask_list);
QFETCH(TestAdSecurityType, exptected_state);
// Add superior
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, superior_mask, QByteArray(), allow_superior);
// Superior should be set
check_state(test_trustee, superior_mask, QByteArray(), exptected_state);
// Subordinate should be set
for (const int &subordinate_mask : subordinate_mask_list) {
check_state(test_trustee, subordinate_mask, subordinate_right_type, exptected_state);
}
// Remove superior
security_descriptor_remove_right(sd, ad.adconfig(), class_list, test_trustee, superior_mask, QByteArray(), allow_superior);
// Superior should be unset
check_state(test_trustee, superior_mask, QByteArray(), TestAdSecurityType_None);
// But subordinates should remain
for (const int &subordinate_mask : subordinate_mask_list) {
check_state(test_trustee, subordinate_mask, subordinate_right_type, exptected_state);
}
}
// When a right is unset, if it has any superiors and
// they are set, they should become unset. For example,
// unsetting "allow read some property" should unset
// "generic read" and "full control".
void ADMCTestAdSecurity::remove_to_unset_superior_data() {
QTest::addColumn<bool>("allow");
QTest::addColumn<QList<int>>("superior_mask_list");
QTest::addColumn<int>("subordinate_mask");
QTest::addColumn<TestAdSecurityType>("state_before_remove");
QTest::newRow("allow generic read") << true << QList<int>({SEC_ADS_GENERIC_READ}) << SEC_ADS_READ_PROP << TestAdSecurityType_Allow;
QTest::newRow("deny generic read") << false << QList<int>({SEC_ADS_GENERIC_READ}) << SEC_ADS_READ_PROP << TestAdSecurityType_Deny;
QTest::newRow("allow generic write") << true << QList<int>({SEC_ADS_GENERIC_WRITE}) << SEC_ADS_WRITE_PROP << TestAdSecurityType_Allow;
QTest::newRow("deny generic write") << false << QList<int>({SEC_ADS_GENERIC_WRITE}) << SEC_ADS_WRITE_PROP << TestAdSecurityType_Deny;
QTest::newRow("allow generic all and read") << true << QList<int>({SEC_ADS_GENERIC_ALL, SEC_ADS_GENERIC_READ}) << SEC_ADS_READ_PROP << TestAdSecurityType_Allow;
QTest::newRow("deny generic all and read") << false << QList<int>({SEC_ADS_GENERIC_ALL, SEC_ADS_GENERIC_READ}) << SEC_ADS_READ_PROP << TestAdSecurityType_Deny;
}
void ADMCTestAdSecurity::remove_to_unset_superior() {
QFETCH(bool, allow);
QFETCH(QList<int>, superior_mask_list);
QFETCH(int, subordinate_mask);
QFETCH(TestAdSecurityType, state_before_remove);
const QByteArray subordinate_right_type = ad.adconfig()->get_right_guid("Web-Information");
// Add superiors
// NOTE: there might be overlap but that's ok
for (const int &superior_mask : superior_mask_list) {
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, superior_mask, QByteArray(), allow);
}
// Superior should be set
for (const int &superior_mask : superior_mask_list) {
check_state(test_trustee, superior_mask, QByteArray(), state_before_remove);
}
// Subordinate should be set
check_state(test_trustee, subordinate_mask, subordinate_right_type, state_before_remove);
// Remove subordinate
security_descriptor_remove_right(sd, ad.adconfig(), class_list, test_trustee, subordinate_mask, subordinate_right_type, allow);
// Superiors should be unset
for (const int &superior_mask : superior_mask_list) {
check_state(test_trustee, superior_mask, QByteArray(), TestAdSecurityType_None);
}
// And subordinates also should be unset
check_state(test_trustee, subordinate_mask, subordinate_right_type, TestAdSecurityType_None);
}
// Setting a right should unset it's opposite superior.
// For example, "Create child" right is subordinate to
// "Full control", so if full control is allowed and
// then you deny "Create child", full control stops
// being allowed.
void ADMCTestAdSecurity::add_to_unset_opposite_superior_data() {
QTest::addColumn<bool>("first_allow");
QTest::addColumn<TestAdSecurityType>("expected_create_child");
QTest::addColumn<TestAdSecurityType>("expected_full_control");
QTest::newRow("allow full control, then deny create child") << true << TestAdSecurityType_Deny << TestAdSecurityType_None;
QTest::newRow("deny full control, then allow create child") << false << TestAdSecurityType_Allow << TestAdSecurityType_None;
}
void ADMCTestAdSecurity::add_to_unset_opposite_superior() {
QFETCH(bool, first_allow);
QFETCH(TestAdSecurityType, expected_create_child);
QFETCH(TestAdSecurityType, expected_full_control);
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, SEC_ADS_GENERIC_ALL, QByteArray(), first_allow);
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, SEC_ADS_CREATE_CHILD, QByteArray(), !first_allow);
check_state(test_trustee, SEC_ADS_CREATE_CHILD, QByteArray(), expected_create_child);
check_state(test_trustee, SEC_ADS_GENERIC_ALL, QByteArray(), expected_full_control);
}
void ADMCTestAdSecurity::check_state(const QByteArray &trustee, const uint32_t access_mask, const QByteArray &object_type, const TestAdSecurityType type) const {
const SecurityRightState state = security_descriptor_get_right(sd, trustee, access_mask, object_type);
const bool inherited_allow = state.get(SecurityRightStateInherited_Yes, SecurityRightStateType_Allow);
const bool inherited_deny = state.get(SecurityRightStateInherited_Yes, SecurityRightStateType_Deny);
const bool object_allow = state.get(SecurityRightStateInherited_No, SecurityRightStateType_Allow);
const bool object_deny = state.get(SecurityRightStateInherited_No, SecurityRightStateType_Deny);
QCOMPARE(inherited_allow, false);
QCOMPARE(inherited_deny, false);
switch (type) {
case TestAdSecurityType_Allow: {
QCOMPARE(object_allow, true);
QCOMPARE(object_deny, false);
break;
}
case TestAdSecurityType_Deny: {
QCOMPARE(object_allow, false);
QCOMPARE(object_deny, true);
break;
}
case TestAdSecurityType_None: {
QCOMPARE(object_allow, false);
QCOMPARE(object_deny, false);
break;
}
}
}
void ADMCTestAdSecurity::load_sd() {
security_descriptor_free(sd);
sd = [&]() {
const AdObject test_user = ad.search_object(test_user_dn);
security_descriptor *out = test_user.get_security_descriptor();
return out;
}();
}
QTEST_MAIN(ADMCTestAdSecurity)
| 17,672
|
C++
|
.cpp
| 321
| 50.137072
| 173
| 0.715022
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,582
|
admc_test_rename_object_dialog.cpp
|
altlinux_admc/tests/admc_test_rename_object_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_rename_object_dialog.h"
#include "adldap.h"
#include "rename_dialogs/rename_user_dialog.h"
#include "ui_rename_user_dialog.h"
void ADMCTestRenameObjectDialog::rename() {
const QString old_name = TEST_USER;
const QString new_name = old_name + "2";
const QString old_dn = test_object_dn(old_name, CLASS_USER);
const QString new_dn = dn_rename(old_dn, new_name);
// Create test object
const bool create_success = ad.object_add(old_dn, CLASS_USER);
QVERIFY(create_success);
QVERIFY(object_exists(old_dn));
// Open rename dialog
auto rename_object_dialog = new RenameUserDialog(ad, old_dn, parent_widget);
rename_object_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(rename_object_dialog, 1000));
rename_object_dialog->ui->name_edit->setText(new_name);
rename_object_dialog->accept();
QVERIFY(object_exists(new_dn));
QCOMPARE(rename_object_dialog->get_new_dn(), new_dn);
}
void ADMCTestRenameObjectDialog::rename_user_autofill() {
const QString old_name = TEST_USER;
const QString old_dn = test_object_dn(old_name, CLASS_USER);
const bool create_success = ad.object_add(old_dn, CLASS_USER);
QVERIFY(create_success);
QVERIFY(object_exists(old_dn));
auto rename_object_dialog = new RenameUserDialog(ad, old_dn, parent_widget);
rename_object_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(rename_object_dialog, 1000));
test_lineedit_autofill(rename_object_dialog->ui->upn_prefix_edit, rename_object_dialog->ui->sam_name_edit);
}
void ADMCTestRenameObjectDialog::trim() {
const QString old_name = TEST_USER;
const QString new_name = QString("%1 new").arg(old_name);
const QString new_name_untrimmed = QString(" %1 ").arg(new_name);
const QString old_dn = test_object_dn(old_name, CLASS_USER);
const QString new_dn = test_object_dn(new_name, CLASS_USER);
// Create test object
const bool create_success = ad.object_add(old_dn, CLASS_USER);
QVERIFY(create_success);
QVERIFY(object_exists(old_dn));
// Open rename dialog
auto rename_object_dialog = new RenameUserDialog(ad, old_dn, parent_widget);
rename_object_dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(rename_object_dialog, 1000));
rename_object_dialog->ui->name_edit->setText(new_name_untrimmed);
rename_object_dialog->accept();
QVERIFY(object_exists(new_dn));
QCOMPARE(rename_object_dialog->get_new_dn(), new_dn);
}
QTEST_MAIN(ADMCTestRenameObjectDialog)
| 3,303
|
C++
|
.cpp
| 72
| 42
| 111
| 0.729907
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,583
|
admc_test_member_of_tab.cpp
|
altlinux_admc/tests/admc_test_member_of_tab.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_member_of_tab.h"
#include "select_dialogs/select_object_dialog.h"
#include "tabs/membership_tab.h"
#include "tabs/ui_membership_tab.h"
#include <QPushButton>
#include <QStandardItemModel>
#include <QTreeView>
#include <QVBoxLayout>
// NOTE: there's a primary group by default hence the offset
// by 1 of all row values
void ADMCTestMemberOfTab::init() {
ADMCTest::init();
view = new QTreeView(parent_widget);
auto primary_button = new QPushButton(parent_widget);
add_button = new QPushButton(parent_widget);
remove_button = new QPushButton(parent_widget);
auto properties_button = new QPushButton(parent_widget);
auto primary_group_label = new QLabel(parent_widget);
edit = new MembershipTabEdit(view, primary_button, add_button, remove_button, properties_button, primary_group_label, MembershipTabType_MemberOf, parent_widget);
model = edit->findChild<QStandardItemModel *>();
QVERIFY(model);
// Create test user
const QString user_name = TEST_USER;
user_dn = test_object_dn(user_name, CLASS_USER);
const bool create_user_success = ad.object_add(user_dn, CLASS_USER);
QVERIFY(create_user_success);
// Create test group
const QString group_name = TEST_GROUP;
group_dn = test_object_dn(group_name, CLASS_GROUP);
const bool create_group_success = ad.object_add(group_dn, CLASS_GROUP);
QVERIFY(create_group_success);
// Load it into the tab
const AdObject object = ad.search_object(user_dn);
edit->load(ad, object);
}
// Loading a group without members should result in empty
// model
void ADMCTestMemberOfTab::load_empty() {
QCOMPARE(model->rowCount(), 1);
}
// Loading a group with members should put members in the
// model
void ADMCTestMemberOfTab::load() {
const bool add_success = ad.group_add_member(group_dn, user_dn);
QVERIFY(add_success);
const AdObject object = ad.search_object(user_dn);
edit->load(ad, object);
QCOMPARE(model->rowCount(), 2);
const bool contains_group = (get_group_row(group_dn) != -1);
QVERIFY(contains_group);
}
int ADMCTestMemberOfTab::get_group_row(const QString &dn) {
const QString group_name = dn_get_name(dn);
for (int row = 0; row < model->rowCount(); row++) {
auto item = model->item(row, 0);
if (item->text() == group_name) {
return row;
}
}
return -1;
}
// Removing members should remove members from model and group
void ADMCTestMemberOfTab::remove() {
load();
const int group_row = get_group_row(group_dn);
const QModelIndex index = model->index(group_row, 0);
view->setCurrentIndex(index);
remove_button->click();
edit->apply(ad, user_dn);
const AdObject updated_object = ad.search_object(user_dn);
const QList<QString> member_list = updated_object.get_strings(ATTRIBUTE_MEMBER_OF);
QCOMPARE(model->rowCount(), 1);
QVERIFY(member_list.isEmpty());
}
void ADMCTestMemberOfTab::add() {
add_button->click();
select_object_dialog_select(group_dn);
// Apply and check object state
edit->apply(ad, user_dn);
const AdObject object = ad.search_object(user_dn);
const QList<QString> member_of_list = object.get_strings(ATTRIBUTE_MEMBER_OF);
QVERIFY(member_of_list.contains(group_dn));
// Check ui state after applying (just in case)
QCOMPARE(model->rowCount(), 2);
const bool contains_after_add = (get_group_row(group_dn) != -1);
QVERIFY(contains_after_add);
}
QTEST_MAIN(ADMCTestMemberOfTab)
| 4,309
|
C++
|
.cpp
| 107
| 36.392523
| 165
| 0.716203
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,584
|
admc_test_list_attribute_dialog.cpp
|
altlinux_admc/tests/admc_test_list_attribute_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_list_attribute_dialog.h"
#include "attribute_dialogs/list_attribute_dialog.h"
#include "attribute_dialogs/string_attribute_dialog.h"
#include "attribute_dialogs/ui_list_attribute_dialog.h"
#include "attribute_dialogs/ui_string_attribute_dialog.h"
#include <QListWidget>
#include <QPlainTextEdit>
#include <QPushButton>
void ADMCTestListAttributeDialog::initTestCase_data() {
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::addColumn<QString>("display_value");
const QList<QByteArray> test_value = {
QByteArray("first"),
QByteArray("second"),
QByteArray("third"),
};
QTest::newRow("list") << test_value << "first";
}
void ADMCTestListAttributeDialog::init() {
ADMCTest::init();
QFETCH_GLOBAL(QList<QByteArray>, value_list);
dialog = new ListAttributeDialog(value_list, ATTRIBUTE_DESCRIPTION, false, parent_widget);
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
list_widget = dialog->ui->list_widget;
add_button = dialog->ui->add_button;
remove_button = dialog->ui->remove_button;
}
void ADMCTestListAttributeDialog::display_value() {
QFETCH_GLOBAL(QString, display_value);
QListWidgetItem *item = list_widget->item(0);
QVERIFY(item);
QCOMPARE(item->text(), display_value);
}
void ADMCTestListAttributeDialog::get_value_list() {
QFETCH_GLOBAL(QList<QByteArray>, value_list);
const QList<QByteArray> actual_value_list = dialog->get_value_list();
QCOMPARE(actual_value_list, value_list);
}
void ADMCTestListAttributeDialog::add() {
add_button->click();
auto string_attribute_dialog = dialog->findChild<StringAttributeDialog *>();
QVERIFY(string_attribute_dialog);
QPlainTextEdit *text_edit = string_attribute_dialog->ui->edit;
const QString new_value = "new value";
text_edit->setPlainText(new_value);
string_attribute_dialog->accept();
QFETCH_GLOBAL(QList<QByteArray>, value_list);
const int expected_new_size = value_list.size() + 1;
const int actual_new_size = list_widget->count();
QCOMPARE(actual_new_size, expected_new_size);
auto added_item = list_widget->item(list_widget->count() - 1);
QVERIFY(added_item);
QCOMPARE(added_item->text(), new_value);
}
void ADMCTestListAttributeDialog::remove() {
list_widget->setCurrentRow(1);
remove_button->click();
QFETCH_GLOBAL(QList<QByteArray>, value_list);
const int expected_new_size = value_list.size() - 1;
const int actual_new_size = list_widget->count();
QCOMPARE(actual_new_size, expected_new_size);
QCOMPARE(list_widget->item(0)->text(), value_list[0]);
QCOMPARE(list_widget->item(1)->text(), value_list[2]);
}
QTEST_MAIN(ADMCTestListAttributeDialog)
| 3,548
|
C++
|
.cpp
| 85
| 37.952941
| 94
| 0.729045
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,585
|
admc_test_sam_name_edit.cpp
|
altlinux_admc/tests/admc_test_sam_name_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_sam_name_edit.h"
#include "attribute_edits/sam_name_edit.h"
#include <QLineEdit>
#define TEST_ATTRIBUTE ATTRIBUTE_FIRST_NAME
void ADMCTestSamNameEdit::init() {
ADMCTest::init();
line_edit = new QLineEdit(parent_widget);
auto domain_edit = new QLineEdit(parent_widget);
edit = new SamNameEdit(line_edit, domain_edit, parent_widget);
}
void ADMCTestSamNameEdit::verify_data() {
QTest::addColumn<QString>("value");
QTest::addColumn<bool>("correct_result");
const QString bad_chars_string = SAM_NAME_BAD_CHARS;
for (int i = 0; i < bad_chars_string.length(); i++) {
const QChar bad_char = bad_chars_string.at(i);
const QString bad_char_string = QString(bad_char);
const QByteArray bad_char_bytes = bad_char_string.toUtf8();
const QString value = QString("test%1value").arg(bad_char);
QTest::newRow(bad_char_bytes.constData()) << value << false;
}
QTest::newRow("ends with dot") << "testvalue." << false;
QTest::newRow("contains dot") << "test.value" << true;
}
void ADMCTestSamNameEdit::verify() {
QFETCH(QString, value);
QFETCH(bool, correct_result);
line_edit->setText(value);
const bool actual_result = edit->verify(ad, QString());
QCOMPARE(actual_result, correct_result);
}
void ADMCTestSamNameEdit::trim() {
const QString dn = test_object_dn(TEST_USER, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
QVERIFY(object_exists(dn));
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
line_edit->setText(" trim-test ");
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const QString actual_sam_name = [&]() {
const AdObject object_after_apply = ad.search_object(dn);
const QString out = object_after_apply.get_string(ATTRIBUTE_SAM_ACCOUNT_NAME);
return out;
}();
const QString expected_sam_name = "trim-test";
QCOMPARE(actual_sam_name, expected_sam_name);
}
QTEST_MAIN(ADMCTestSamNameEdit)
| 2,876
|
C++
|
.cpp
| 69
| 37.434783
| 86
| 0.705502
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,586
|
admc_test_upn_edit.cpp
|
altlinux_admc/tests/admc_test_upn_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_upn_edit.h"
#include "attribute_edits/upn_edit.h"
#include <QComboBox>
#include <QFormLayout>
#include <QLineEdit>
// NOTE: we have to make sure that test suffix doesn't
// already exist on the test domain, hence the wacky
// name
#define TEST_SUFFIX "totally-unique-test-suffix.zone"
void ADMCTestUpnEdit::init() {
ADMCTest::init();
prefix_edit = new QLineEdit();
suffix_edit = new QComboBox();
upn_edit = new UpnEdit(prefix_edit, suffix_edit, parent_widget);
upn_edit->init_suffixes(ad);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
const QString test_upn = QString("%1@%2").arg(name, TEST_SUFFIX);
const bool replace_success = ad.attribute_replace_string(dn, ATTRIBUTE_USER_PRINCIPAL_NAME, test_upn);
QVERIFY(replace_success);
const AdObject object = ad.search_object(dn);
upn_edit->load(ad, object);
}
void ADMCTestUpnEdit::length_limit() {
const int prefix_max_length = prefix_edit->maxLength();
const int correct_prefix_max_length = [&]() {
const int total_range_upper = ad.adconfig()->get_attribute_range_upper(ATTRIBUTE_USER_PRINCIPAL_NAME);
const int suffix_length = suffix_edit->currentText().length();
const int out = total_range_upper - 1 - suffix_length;
return out;
}();
QCOMPARE(prefix_max_length, correct_prefix_max_length);
}
// Edit should load prefix and suffix into widgets correctly
void ADMCTestUpnEdit::test_load() {
const QString prefix = prefix_edit->text();
QCOMPARE(prefix, TEST_USER);
}
// edited() signal should be emitted when prefix or suffix
// widgets are edited
void ADMCTestUpnEdit::test_emit_edited() {
bool edited_signal_emitted = false;
connect(
upn_edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
prefix_edit->setText("test");
QVERIFY(edited_signal_emitted);
edited_signal_emitted = false;
const int suffix_count = suffix_edit->count();
QVERIFY((suffix_count > 1));
const int changed_index = [this]() {
if (suffix_edit->currentIndex() == 0) {
return 1;
} else {
return 0;
}
}();
suffix_edit->setCurrentIndex(changed_index);
QVERIFY(edited_signal_emitted);
}
void ADMCTestUpnEdit::apply_unmodified() {
test_edit_apply_unmodified(upn_edit, dn);
}
// Edit should apply changes to suffix
void ADMCTestUpnEdit::test_apply_suffix() {
change_suffix_in_edit();
const bool apply_success = upn_edit->apply(ad, dn);
QVERIFY(apply_success);
QVERIFY2(edit_state_equals_to_server_state(), "Failed to change upn suffix");
}
// Edit should apply changes to prefix
void ADMCTestUpnEdit::test_apply_prefix() {
prefix_edit->setText("test-new-prefix");
const bool apply_success = upn_edit->apply(ad, dn);
QVERIFY(apply_success);
QVERIFY2(edit_state_equals_to_server_state(), "Failed to change upn prefix");
}
// Edit should apply changes to prefix
void ADMCTestUpnEdit::test_apply_prefix_and_suffix() {
change_suffix_in_edit();
prefix_edit->setText("test-new-prefix2");
const bool apply_success = upn_edit->apply(ad, dn);
QVERIFY(apply_success);
QVERIFY2(edit_state_equals_to_server_state(), "Failed to change upn prefix and suffix");
}
// Edit should reset to server state after load() call
void ADMCTestUpnEdit::test_reset() {
change_suffix_in_edit();
prefix_edit->setText("test-new-prefix3");
const AdObject object = ad.search_object(dn);
upn_edit->load(ad, object);
QVERIFY2(edit_state_equals_to_server_state(), "Failed to reset");
}
QString ADMCTestUpnEdit::get_current_upn() {
const QString prefix = prefix_edit->text();
const QString suffix = suffix_edit->currentText();
const QString upn = QString("%1@%2").arg(prefix, suffix);
return upn;
}
bool ADMCTestUpnEdit::edit_state_equals_to_server_state() {
const AdObject object = ad.search_object(dn);
const QString server_upn = object.get_string(ATTRIBUTE_USER_PRINCIPAL_NAME);
const QString edit_upn = get_current_upn();
return (edit_upn == server_upn);
}
// Change to next suffix, not equal to current one
void ADMCTestUpnEdit::change_suffix_in_edit() {
const int new_suffix_index = [this]() {
const QString current_suffix = suffix_edit->currentText();
for (int i = 0; i < suffix_edit->count(); i++) {
const QString suffix = suffix_edit->itemText(i);
if (suffix != current_suffix) {
return i;
}
}
return -1;
}();
QVERIFY2((new_suffix_index != -1), "Failed to find different suffix");
suffix_edit->setCurrentIndex(new_suffix_index);
}
void ADMCTestUpnEdit::verify_bad_chars_data() {
QTest::addColumn<QString>("value");
QTest::addColumn<bool>("correct_result");
const QString bad_chars_string = UPN_BAD_CHARS;
for (int i = 0; i < bad_chars_string.length(); i++) {
const QChar bad_char = bad_chars_string.at(i);
const QString bad_char_string = QString(bad_char);
const QByteArray bad_char_bytes = bad_char_string.toUtf8();
const QString value = QString("test%1value").arg(bad_char);
QTest::newRow(bad_char_bytes.constData()) << value << false;
}
QTest::newRow("starts with space") << " testvalue" << false;
QTest::newRow("ends with space") << "testvalue " << false;
QTest::newRow("contains space inside") << "test value" << true;
}
void ADMCTestUpnEdit::verify_bad_chars() {
QFETCH(QString, value);
QFETCH(bool, correct_result);
prefix_edit->setText(value);
const bool actual_result = upn_edit->verify(ad, QString());
QCOMPARE(actual_result, correct_result);
}
// verify() must return false if there's a user with the
// same upn
void ADMCTestUpnEdit::verify_conflict() {
// Create user with conflicting upn
const QString conflict_name = "conflicting-upn-test-user";
const QString conflict_dn = test_object_dn(conflict_name, CLASS_USER);
const bool create_success = ad.object_add(conflict_dn, CLASS_USER);
QVERIFY(create_success);
const QString conflicting_upn = QString("%1@%2").arg(conflict_name, TEST_SUFFIX);
const bool replace_success = ad.attribute_replace_string(conflict_dn, ATTRIBUTE_USER_PRINCIPAL_NAME, conflicting_upn);
QVERIFY(replace_success);
// Set input of upn edit so that it conflicts with
// the conflicting user that we have setup. After
// that verify should fail.
prefix_edit->setText(conflict_name);
suffix_edit->setCurrentText(TEST_SUFFIX);
const bool verify_success = upn_edit->verify(ad, dn);
QVERIFY2(!verify_success, "verify() didn't notice upn conflict");
}
QTEST_MAIN(ADMCTestUpnEdit)
| 7,731
|
C++
|
.cpp
| 187
| 36.679144
| 122
| 0.694352
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,587
|
admc_test_dn_edit.cpp
|
altlinux_admc/tests/admc_test_dn_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_dn_edit.h"
#include "attribute_edits/dn_edit.h"
#include <QLineEdit>
void ADMCTestDNEdit::init() {
ADMCTest::init();
line_edit = new QLineEdit(parent_widget);
edit = new DNEdit(line_edit, parent_widget);
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
void ADMCTestDNEdit::load() {
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
const QString actual_value = line_edit->text();
const QString expected_value = dn_canonical(dn);
QCOMPARE(actual_value, expected_value);
}
QTEST_MAIN(ADMCTestDNEdit)
| 1,503
|
C++
|
.cpp
| 40
| 34.575
| 72
| 0.732278
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,588
|
admc_test_expiry_edit.cpp
|
altlinux_admc/tests/admc_test_expiry_edit.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_expiry_edit.h"
#include "attribute_edits/expiry_edit.h"
#include "attribute_edits/expiry_widget.h"
#include "attribute_edits/ui_expiry_widget.h"
#include "globals.h"
#include <QDateEdit>
#include <QFormLayout>
#include <QRadioButton>
void ADMCTestExpiryEdit::initTestCase_data() {
QTest::addColumn<QString>("button_name");
QTest::addColumn<QDate>("date");
QTest::addColumn<QString>("value");
QTest::newRow("end of") << "end_of_check" << QDate(2011, 11, 11) << "129655295400000000";
QTest::newRow("never") << "never_check" << QDate() << AD_LARGE_INTEGER_DATETIME_NEVER_2;
;
}
void ADMCTestExpiryEdit::init() {
ADMCTest::init();
auto widget = new ExpiryWidget(parent_widget);
edit = new ExpiryEdit(widget, parent_widget);
date_edit = widget->ui->date_edit;
QFETCH_GLOBAL(QString, button_name);
const QHash<QString, QRadioButton *> button_map = {
{"end_of_check", widget->ui->end_of_check},
{"never_check", widget->ui->never_check},
};
button = button_map[button_name];
// Create test user
const QString name = TEST_USER;
dn = test_object_dn(name, CLASS_USER);
const bool create_success = ad.object_add(dn, CLASS_USER);
QVERIFY(create_success);
}
void ADMCTestExpiryEdit::edited_signal() {
bool edited_signal_emitted = false;
connect(
edit, &AttributeEdit::edited,
this,
[&edited_signal_emitted]() {
edited_signal_emitted = true;
});
button->setChecked(true);
QVERIFY(edited_signal_emitted);
}
void ADMCTestExpiryEdit::load() {
QFETCH_GLOBAL(QDate, date);
QFETCH_GLOBAL(QString, value);
ad.attribute_replace_string(dn, ATTRIBUTE_ACCOUNT_EXPIRES, value);
const AdObject object = ad.search_object(dn);
edit->load(ad, object);
QVERIFY(button->isChecked());
if (date_edit->isEnabled()) {
QCOMPARE(date_edit->date(), date);
}
}
void ADMCTestExpiryEdit::apply_unmodified() {
test_edit_apply_unmodified(edit, dn);
}
void ADMCTestExpiryEdit::apply() {
QFETCH_GLOBAL(QDate, date);
QFETCH_GLOBAL(QString, value);
// Replace value into something different before testing
ad.attribute_replace_string(dn, ATTRIBUTE_ACCOUNT_EXPIRES, "129655295400000001");
button->setChecked(true);
date_edit->setDate(date);
const bool apply_success = edit->apply(ad, dn);
QVERIFY(apply_success);
const AdObject updated_object = ad.search_object(dn);
const QString expiry_string = updated_object.get_string(ATTRIBUTE_ACCOUNT_EXPIRES);
QCOMPARE(expiry_string, value);
}
QTEST_MAIN(ADMCTestExpiryEdit)
| 3,423
|
C++
|
.cpp
| 91
| 33.527473
| 93
| 0.707767
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,589
|
admc_test_string_attribute_dialog.cpp
|
altlinux_admc/tests/admc_test_string_attribute_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_string_attribute_dialog.h"
#include "attribute_dialogs/string_attribute_dialog.h"
#include "attribute_dialogs/ui_string_attribute_dialog.h"
#include <QPlainTextEdit>
#define TEST_ATTRIBUTE ATTRIBUTE_CN
void ADMCTestStringAttributeDialog::init_edit(const QList<QByteArray> &value_list) {
dialog = new StringAttributeDialog(value_list, TEST_ATTRIBUTE, false, parent_widget);
dialog->open();
QVERIFY(QTest::qWaitForWindowExposed(dialog, 1000));
text_edit = dialog->ui->edit;
}
void ADMCTestStringAttributeDialog::display_value_data() {
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::addColumn<QString>("expected_display_value");
QTest::newRow("empty") << QList<QByteArray>() << "";
QTest::newRow("non-empty") << QList<QByteArray>({"hello"}) << "hello";
}
void ADMCTestStringAttributeDialog::display_value() {
QFETCH(QList<QByteArray>, value_list);
QFETCH(QString, expected_display_value);
init_edit(value_list);
const QString actual_display_value = text_edit->toPlainText();
QCOMPARE(actual_display_value, expected_display_value);
}
void ADMCTestStringAttributeDialog::get_value_list_data() {
QTest::addColumn<QList<QByteArray>>("value_list");
QTest::newRow("empty") << QList<QByteArray>();
QTest::newRow("non-empty") << QList<QByteArray>({"hello"});
}
void ADMCTestStringAttributeDialog::get_value_list() {
QFETCH(QList<QByteArray>, value_list);
init_edit(value_list);
const QList<QByteArray> actual_value_list = dialog->get_value_list();
const QList<QByteArray> expected_value_list = value_list;
QCOMPARE(actual_value_list, expected_value_list);
}
void ADMCTestStringAttributeDialog::limit_length() {
const auto value_list = QList<QByteArray>({"hello"});
init_edit(value_list);
const int range_upper = ad.adconfig()->get_attribute_range_upper(TEST_ATTRIBUTE);
QVERIFY(range_upper > 0);
const QString new_value = QString(range_upper + 10, 'a');
text_edit->setPlainText(new_value);
const QString current_value = text_edit->toPlainText();
const int current_value_length = current_value.length();
QCOMPARE(current_value_length, range_upper);
}
QTEST_MAIN(ADMCTestStringAttributeDialog)
| 3,030
|
C++
|
.cpp
| 67
| 41.80597
| 89
| 0.742089
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,590
|
main_window.cpp
|
altlinux_admc/src/admc/main_window.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "main_window.h"
#include "ui_main_window.h"
#include "about_dialog.h"
#include "adldap.h"
#include "attribute_edits/country_combo.h"
#include "changelog_dialog.h"
#include "config.h"
#include "connection_options_dialog.h"
#include "console_impls/all_policies_folder_impl.h"
#include "console_impls/item_type.h"
#include "console_impls/object_impl.h"
#include "console_impls/policy_impl.h"
#include "console_impls/policy_ou_impl.h"
#include "console_impls/policy_root_impl.h"
#include "console_impls/query_folder_impl.h"
#include "console_impls/query_item_impl.h"
#include "console_widget/console_widget.h"
#include "fsmo/fsmo_dialog.h"
#include "globals.h"
#include "main_window_connection_error.h"
#include "settings.h"
#include "status.h"
#include "utils.h"
#include "fsmo/fsmo_utils.h"
#include "icon_manager/icon_manager.h"
#include "console_impls/domain_info_impl.h"
#include <QDesktopServices>
#include <QLabel>
#include <QModelIndex>
MainWindow::MainWindow(AdInterface &ad, QWidget *parent)
: QMainWindow(parent) {
ui = new Ui::MainWindow();
ui->setupUi(this);
country_combo_load_data();
g_status->init(ui->statusbar, ui->message_log_edit);
const QMap<QString, QAction*> category_action_map = {
{OBJECT_CATEGORY_OU, ui->action_create_ou},
{OBJECT_CATEGORY_PERSON, ui->action_create_user},
{OBJECT_CATEGORY_GROUP, ui->action_create_group},
};
g_icon_manager->init(category_action_map);
login_label = new QLabel();
login_label->setText(ad.client_user());
ui->statusbar->addPermanentWidget(login_label);
ui->statusbar->addAction(ui->action_show_login);
//
// Console
//
auto domain_info_impl = new DomainInfoImpl(ui->console);
ui->console->register_impl(ItemType_DomainInfo, domain_info_impl);
auto object_impl = new ObjectImpl(ui->console);
ui->console->register_impl(ItemType_Object, object_impl);
auto policy_root_impl = new PolicyRootImpl(ui->console);
ui->console->register_impl(ItemType_PolicyRoot, policy_root_impl);
auto all_policies_folder_impl = new AllPoliciesFolderImpl(ui->console);
ui->console->register_impl(ItemType_AllPoliciesFolder, all_policies_folder_impl);
auto policy_ou_impl = new PolicyOUImpl(ui->console);
ui->console->register_impl(ItemType_PolicyOU, policy_ou_impl);
auto policy_impl = new PolicyImpl(ui->console);
ui->console->register_impl(ItemType_Policy, policy_impl);
auto query_item_impl = new QueryItemImpl(ui->console);
ui->console->register_impl(ItemType_QueryItem, query_item_impl);
auto query_folder_impl = new QueryFolderImpl(ui->console);
ui->console->register_impl(ItemType_QueryFolder, query_folder_impl);
query_item_impl->set_query_folder_impl(query_folder_impl);
object_impl->set_toolbar_actions(ui->action_create_user, ui->action_create_group, ui->action_create_ou);
// Setup console
const ConsoleWidgetActions console_actions = [&]() {
ConsoleWidgetActions out;
out.navigate_up = ui->action_navigate_up;
out.navigate_back = ui->action_navigate_back;
out.navigate_forward = ui->action_navigate_forward;
out.refresh = ui->action_refresh;
out.customize_columns = ui->action_customize_columns;
out.view_icons = ui->action_view_icons;
out.view_list = ui->action_view_list;
out.view_detail = ui->action_view_detail;
out.toggle_console_tree = ui->action_toggle_console_tree;
out.toggle_description_bar = ui->action_toggle_description_bar;
return out;
}();
ui->console->set_actions(console_actions);
// NOTE: "Action" menu actions need to be filled by the
// console
ui->console->setup_menubar_action_menu(ui->menu_action);
// NOTE: toolbar and message log(dock widget) have built
// in toggle actions, but there's no way to add them
// through designer so add them here.
ui->menu_view->insertAction(ui->action_toggle_message_log, ui->message_log->toggleViewAction());
ui->menu_view->insertAction(ui->action_toggle_toolbar, ui->toolbar->toggleViewAction());
ui->menu_view->removeAction(ui->action_toggle_message_log);
ui->menu_view->removeAction(ui->action_toggle_toolbar);
// Load console tree's
domain_info_impl->load_domain_info_item(ad);
ui->console->set_current_scope(ui->console->domain_info_index());
console_object_tree_init(ui->console, ad);
console_policy_tree_init(ui->console);
console_query_tree_init(ui->console);
ui->console->expand_item(ui->console->domain_info_index());
// Set current scope to object head to load it
const QModelIndex object_tree_root = get_object_tree_root(ui->console);
if (object_tree_root.isValid()) {
ui->console->set_current_scope(object_tree_root);
}
// Display any errors that happened when loading the
// console
g_status->display_ad_messages(ad, this);
//
// Restore state
//
// NOTE: must restore state after everything is setup
const QVariant console_widget_state = settings_get_variant(SETTING_console_widget_state);
ui->console->restore_state(console_widget_state);
const bool restored_geometry = settings_restore_geometry(SETTING_main_window_geometry, this);
if (!restored_geometry) {
resize(1024, 768);
center_widget(this);
}
const QByteArray state = settings_get_variant(SETTING_main_window_state).toByteArray();
if (!state.isEmpty()) {
restoreState(state);
} else {
// Hide message log by default
ui->message_log->hide();
}
const bool first_time_opening_this_version = []() {
const QString last_version = settings_get_variant(SETTING_last_opened_version).toString();
return (last_version != ADMC_VERSION);
}();
if (first_time_opening_this_version) {
settings_set_variant(SETTING_last_opened_version, ADMC_VERSION);
open_changelog();
}
//
// Setup theme actions
//
const QStringList theme_list = g_icon_manager->get_available_themes();
const QLocale current_locale = settings_get_variant(SETTING_locale).toLocale();
auto theme_action_group = new QActionGroup(this);
for (const QString &theme : theme_list) {
const QString localized_name = g_icon_manager->get_localized_theme_name(current_locale, theme);
const auto action = new QAction(localized_name, theme_action_group);
action->setCheckable(true);
theme_action_group->addAction(action);
bool is_checked;
const QString current_theme = settings_get_variant(SETTING_current_icon_theme).toString();
current_theme == theme ? is_checked = true : is_checked = false;
action->setChecked(is_checked);
ui->menu_theme->addAction(action);
connect(
action, &QAction::triggered,
this,
[this, theme](bool checked) {
if (checked == false)
return;
g_icon_manager->set_theme(theme);
update();
// TODO: Replace total tree updating from base
// by tree item icons updating corresponding its item type.
// Add corresponding function like update_console_tree_icons(ConsoleWidget*)
// to icon manager
reload_console_tree();
});
}
//
// Setup language actions
//
const QList<QLocale::Language> language_list = {
QLocale::English,
QLocale::Russian,
};
auto language_group = new QActionGroup(this);
for (const QLocale::Language &language : language_list) {
const QLocale locale(language);
const QString language_name = [locale]() {
// NOTE: Russian nativeLanguageName starts with lowercase letter for some reason
QString name_out = locale.nativeLanguageName();
const QChar first_letter_uppercased = name_out[0].toUpper();
name_out.replace(0, 1, first_letter_uppercased);
return name_out;
}();
const auto action = new QAction(language_name, language_group);
action->setCheckable(true);
language_group->addAction(action);
const bool is_checked = [=]() {
const QLocale current_locale = settings_get_variant(SETTING_locale).toLocale();
return (current_locale.language() == locale.language());
}();
action->setChecked(is_checked);
ui->menu_language->addAction(action);
connect(
action, &QAction::triggered,
this,
[this, language](bool checked) {
if (checked) {
settings_set_variant(SETTING_locale, QLocale(language));
message_box_information(this, tr("Info"), tr("Restart the app to switch to the selected language."));
}
});
}
//
// Connect
//
connect(
ui->action_connection_options, &QAction::triggered,
this, &MainWindow::open_connection_options);
connect(
ui->action_edit_fsmo_roles, &QAction::triggered,
this, &MainWindow::edit_fsmo_roles);
connect(
ui->action_quit, &QAction::triggered,
this, &MainWindow::close);
connect(
ui->action_manual, &QAction::triggered,
this, &MainWindow::open_manual);
connect(
ui->action_changelog, &QAction::triggered,
this, &MainWindow::open_changelog);
connect(
ui->action_about, &QAction::triggered,
this, &MainWindow::open_about);
connect(
ui->action_filter_objects, &QAction::triggered,
object_impl, &ObjectImpl::open_console_filter_dialog);
const QHash<QString, QAction *> bool_action_map = {
{SETTING_confirm_actions, ui->action_confirm_actions},
{SETTING_last_name_before_first_name, ui->action_last_name_order},
{SETTING_log_searches, ui->action_log_searches},
{SETTING_timestamp_log, ui->action_timestamps},
{SETTING_show_login, ui->action_show_login},
{SETTING_show_non_containers_in_console_tree, ui->action_show_noncontainers},
{SETTING_advanced_features, ui->action_advanced_features},
{SETTING_load_optional_attribute_values, ui->action_load_optional_values},
};
const QList<QString> simple_setting_list = {
SETTING_confirm_actions,
SETTING_last_name_before_first_name,
SETTING_log_searches,
SETTING_timestamp_log,
SETTING_show_login,
SETTING_load_optional_attribute_values
};
for (const QString &setting : bool_action_map.keys()) {
QAction *action = bool_action_map[setting];
const bool setting_enabled = settings_get_variant(setting).toBool();
action->setChecked(setting_enabled);
}
// Connect setting actions so that they update setting
// values
for (const QString &setting : simple_setting_list) {
QAction *action = bool_action_map[setting];
connect(
action, &QAction::toggled,
this,
[setting](bool checked) {
settings_set_variant(setting, checked);
});
}
// NOTE: For complex settings, we need to refresh object
// tree after setting changes. Because call order of
// slots is undefined we can't just make multiple slots,
// so need to use a custom slot.
const QList<QString> complex_setting_list = {
SETTING_show_non_containers_in_console_tree,
SETTING_advanced_features,
};
for (const QString &setting : complex_setting_list) {
QAction *action = bool_action_map[setting];
connect(
action, &QAction::toggled,
this,
[setting, object_impl](bool checked) {
settings_set_variant(setting, checked);
object_impl->refresh_tree();
});
}
// NOTE: Call these slots now to load initial state
connect(
ui->action_log_searches, &QAction::triggered,
this, &MainWindow::on_log_searches_changed);
on_log_searches_changed();
connect(
ui->action_show_login, &QAction::triggered,
this, &MainWindow::on_show_login_changed);
on_show_login_changed();
if (!current_dc_is_master_for_role(ad, FSMORole_PDCEmulation)) {
g_status->add_message(tr("You are connected to DC without PDC-Emulator role"), StatusType_Success);
}
}
MainWindow::~MainWindow() {
delete ui;
}
void MainWindow::closeEvent(QCloseEvent *event) {
const QByteArray geometry = saveGeometry();
settings_set_variant(SETTING_main_window_geometry, geometry);
const QByteArray state = saveState();
settings_set_variant(SETTING_main_window_state, state);
const QVariant console_state = ui->console->save_state();
settings_set_variant(SETTING_console_widget_state, console_state);
QMainWindow::closeEvent(event);
}
void MainWindow::on_log_searches_changed() {
const bool enabled = ui->action_log_searches->isChecked();
AdInterface::set_log_searches(enabled);
}
void MainWindow::on_show_login_changed() {
const bool enabled = ui->action_show_login->isChecked();
login_label->setVisible(enabled);
}
void MainWindow::open_manual() {
const QUrl manual_url = QUrl("https://www.altlinux.org/%D0%93%D1%80%D1%83%D0%BF%D0%BF%D0%BE%D0%B2%D1%8B%D0%B5_%D0%BF%D0%BE%D0%BB%D0%B8%D1%82%D0%B8%D0%BA%D0%B8/ADMC");
QDesktopServices::openUrl(manual_url);
}
void MainWindow::open_connection_options() {
auto dialog = new ConnectionOptionsDialog(this);
dialog->open();
connect(dialog, &ConnectionOptionsDialog::host_changed,
[this](const QString &host) {
show_busy_indicator();
reload_console_tree();
hide_busy_indicator();
g_status->add_message(tr("Connected to host ") + host, StatusType_Success);
});
}
void MainWindow::open_changelog() {
auto changelog_dialog = new ChangelogDialog(this);
changelog_dialog->open();
}
void MainWindow::open_about() {
auto about_dialog = new AboutDialog(this);
about_dialog->open();
}
void MainWindow::edit_fsmo_roles() {
AdInterface ad;
if (ad_failed(ad, this)) {
return;
}
auto dialog = new FSMODialog(ad, this);
dialog->open();
connect(dialog, &FSMODialog::master_changed, ui->console, &ConsoleWidget::fsmo_master_changed);
}
void MainWindow::reload_console_tree() {
ui->console->refresh_scope(ui->console->domain_info_index());
}
| 15,366
|
C++
|
.cpp
| 363
| 35.69146
| 170
| 0.671291
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,591
|
connection_options_dialog.cpp
|
altlinux_admc/src/admc/connection_options_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "connection_options_dialog.h"
#include "ui_connection_options_dialog.h"
#include "adldap.h"
#include "settings.h"
#include "utils.h"
#include "fsmo/fsmo_utils.h"
#include "globals.h"
#include "status.h"
#include <QPushButton>
#include <functional>
const QString CERT_STRATEGY_NEVER = CERT_STRATEGY_NEVER_define;
const QString CERT_STRATEGY_HARD = "hard";
const QString CERT_STRATEGY_DEMAND = "demand";
const QString CERT_STRATEGY_ALLOW = "allow";
const QString CERT_STRATEGY_TRY = "try";
ConnectionOptionsDialog::ConnectionOptionsDialog(QWidget *parent)
: QDialog(parent) {
ui = new Ui::ConnectionOptionsDialog();
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
const QList<QString> require_cert_list = {
CERT_STRATEGY_NEVER,
CERT_STRATEGY_HARD,
CERT_STRATEGY_DEMAND,
CERT_STRATEGY_ALLOW,
CERT_STRATEGY_TRY,
};
for (const QString &string : require_cert_list) {
ui->cert_combo->addItem(string);
}
// Load saved options
const int port = settings_get_variant(SETTING_port).toInt();
ui->port_spinbox->setValue(port);
const bool sasl_nocanon = settings_get_variant(SETTING_sasl_nocanon).toBool();
ui->canonize_check->setChecked(sasl_nocanon);
const QString cert_strategy = settings_get_variant(SETTING_cert_strategy).toString();
const int cert_strategy_index = ui->cert_combo->findText(cert_strategy);
ui->cert_combo->setCurrentIndex(cert_strategy_index);
default_domain = get_default_domain_from_krb5();
default_host_list = get_domain_hosts(default_domain, QString());
custom_domain = settings_get_variant(SETTING_custom_domain).toString();
custom_host_list = get_domain_hosts(custom_domain, QString());
// Populate hosts list
bool domain_is_default = settings_get_variant(SETTING_domain_is_default).toBool();
QStringList host_list;
QString domain;
if (domain_is_default) {
domain = default_domain;
host_list = default_host_list;
ui->host_default_button->setChecked(true);
ui->domain_custom_edit->setEnabled(false);
ui->domain_custom_edit->setText(default_domain);
ui->get_hosts_button->setVisible(false);
}
else {
domain = custom_domain;
host_list = custom_host_list;
ui->host_custom_button->setChecked(true);
ui->domain_custom_edit->setEnabled(true);
ui->domain_custom_edit->setText(custom_domain);
ui->get_hosts_button->setVisible(true);
}
any_hosts_available = !host_list.isEmpty();
if (any_hosts_available) {
ui->host_warning_label->setVisible(false);
for (const QString &host : host_list) {
ui->host_select_list->addItem(host);
}
set_saved_host_current_item();
} else {
ui->host_warning_label->setVisible(true);
}
settings_setup_dialog_geometry(SETTING_connection_options_dialog_geometry, this);
connect(ui->button_box->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked,
this, &ConnectionOptionsDialog::load_default_options);
connect(ui->host_default_button, &QRadioButton::toggled,
this, &ConnectionOptionsDialog::host_button_toggled);
connect(ui->get_hosts_button, &QPushButton::clicked,
this, &ConnectionOptionsDialog::get_hosts);
}
ConnectionOptionsDialog::~ConnectionOptionsDialog() {
delete ui;
}
void ConnectionOptionsDialog::accept() {
if (any_hosts_available) {
const bool any_host_selected = !ui->host_select_list->selectedItems().isEmpty();
if (!any_host_selected) {
message_box_warning(this, tr("Error"), tr("Select a host."));
return;
}
}
const int port = ui->port_spinbox->value();
const bool sasl_nocanon = ui->canonize_check->isChecked();
const QString cert_strategy = ui->cert_combo->currentText();
QString selected_host;
QListWidgetItem *item = ui->host_select_list->currentItem();
if (item == nullptr) {
selected_host = QString();
}
else {
selected_host = item->text();
}
const bool domain_was_default = settings_get_variant(SETTING_domain_is_default).toBool();
const bool domain_is_default = ui->host_default_button->isChecked();
const bool custom_domain_changed = settings_get_variant(SETTING_custom_domain).toString() != custom_domain;
const QHash<QString, QVariant> settings = {
{SETTING_port, port},
{SETTING_sasl_nocanon, sasl_nocanon},
{SETTING_cert_strategy, cert_strategy},
{SETTING_host, selected_host},
{SETTING_custom_domain, custom_domain},
{SETTING_domain_is_default, domain_is_default}
};
load_connection_options(settings);
AdInterface ad;
if (ad_failed(ad, parentWidget())) {
// load back options from config
load_connection_options();
return;
}
for (const QString setting : settings.keys()) {
settings_set_variant(setting, settings.value(setting));
}
const bool domain_is_changed = (domain_was_default != domain_is_default) || custom_domain_changed;
if (domain_is_changed) {
load_g_adconfig(ad);
}
emit host_changed(selected_host);
if (!current_dc_is_master_for_role(ad, FSMORole_PDCEmulation)) {
if (gpo_edit_without_PDC_disabled)
g_status->add_message(tr("You are connected to DC without PDC-Emulator role. "
"Group policy editing is prohibited by the setting."), StatusType_Success);
else
g_status->add_message(tr("You are connected to DC without PDC-Emulator role. "
"Group policy editing is available."), StatusType_Success);
}
QDialog::accept();
}
void ConnectionOptionsDialog::load_default_options() {
ui->port_spinbox->setValue(0);
ui->canonize_check->setChecked(true);
const int never_index = ui->cert_combo->findText(CERT_STRATEGY_NEVER);
ui->cert_combo->setCurrentIndex(never_index);
if (any_hosts_available) {
ui->host_default_button->setChecked(true);
ui->host_select_list->setCurrentRow(0);
}
}
void ConnectionOptionsDialog::set_saved_host_current_item()
{
const QString saved_host = settings_get_variant(SETTING_host).toString();
if (!saved_host.isEmpty()) {
const QList<QListWidgetItem *> item_list = ui->host_select_list->findItems(saved_host, Qt::MatchExactly);
const bool saved_host_is_in_list = !item_list.isEmpty();
if (saved_host_is_in_list) {
QListWidgetItem *item = item_list[0];
ui->host_select_list->setCurrentItem(item);
}
} else {
// If saved host is empty, select first available
// host in select list
ui->host_select_list->setCurrentRow(0);
}
}
void ConnectionOptionsDialog::host_button_toggled(bool is_default_checked) {
ui->host_select_list->clear();
ui->host_warning_label->setVisible(false);
if (is_default_checked) {
ui->domain_custom_edit->setEnabled(false);
ui->domain_custom_edit->setText(default_domain);
ui->domain_custom_edit->setPlaceholderText(QString());
ui->get_hosts_button->setVisible(false);
if (default_host_list.isEmpty()) {
ui->host_warning_label->setVisible(true);
return;
}
else
ui->host_select_list->addItems(default_host_list);
}
else {
ui->domain_custom_edit->setEnabled(true);
ui->domain_custom_edit->setText(custom_domain);
ui->domain_custom_edit->setPlaceholderText("CUSTOM.DOMAIN.COM");
ui->get_hosts_button->setVisible(true);
if (custom_host_list.isEmpty()) {
ui->host_warning_label->setVisible(true);
return;
}
else
ui->host_select_list->addItems(custom_host_list);
}
set_saved_host_current_item();
}
void ConnectionOptionsDialog::get_hosts() {
ui->host_select_list->clear();
QString domain = ui->domain_custom_edit->text();
QStringList hosts = get_domain_hosts(domain, QString());
if (hosts.isEmpty()) {
ui->host_warning_label->setVisible(true);
}
else {
ui->host_warning_label->setVisible(false);
custom_domain = domain;
ui->host_select_list->addItems(hosts);
custom_host_list = hosts;
ui->host_select_list->setCurrentRow(0);
}
}
void load_connection_options(const QHash<QString, QVariant> &settings) {
std::function<QVariant(const QString &setting)> get_setting;
if (settings.isEmpty()) {
get_setting = [](const QString &setting) {
QVariant out = settings_get_variant(setting);
return out;
};
}
else {
get_setting = [settings](const QString &setting) {
QVariant out = settings[setting];
return out;
};
}
bool domain_is_default = true;
if (get_setting(SETTING_domain_is_default).isValid())
domain_is_default = get_setting(SETTING_domain_is_default).toBool();
AdInterface::set_domain_is_default(domain_is_default);
const QString custom_domain = get_setting(SETTING_custom_domain).toString();
AdInterface::set_custom_domain(custom_domain);
const QString saved_dc = get_setting(SETTING_host).toString();
AdInterface::set_dc(saved_dc);
const QVariant sasl_nocanon = get_setting(SETTING_sasl_nocanon);
if (sasl_nocanon.isValid()) {
AdInterface::set_sasl_nocanon(sasl_nocanon.toBool());
} else {
AdInterface::set_sasl_nocanon(true);
}
const QVariant port = get_setting(SETTING_port);
if (port.isValid()) {
AdInterface::set_port(port.toInt());
} else {
AdInterface::set_port(0);
}
const QString cert_strategy_string = get_setting(SETTING_cert_strategy).toString();
const QHash<QString, CertStrategy> cert_strategy_map = {
{CERT_STRATEGY_NEVER, CertStrategy_Never},
{CERT_STRATEGY_HARD, CertStrategy_Hard},
{CERT_STRATEGY_DEMAND, CertStrategy_Demand},
{CERT_STRATEGY_ALLOW, CertStrategy_Allow},
{CERT_STRATEGY_TRY, CertStrategy_Try},
};
const CertStrategy cert_strategy = cert_strategy_map.value(cert_strategy_string, CertStrategy_Never);
AdInterface::set_cert_strategy(cert_strategy);
}
| 11,184
|
C++
|
.cpp
| 272
| 34.551471
| 113
| 0.670628
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,592
|
tab_widget.cpp
|
altlinux_admc/src/admc/tab_widget.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tab_widget.h"
#include "ui_tab_widget.h"
// TODO: a lot of code has grown here that is used only
// by properties dialog. Other places(fsmo and multi
// properties) only use add_tab() and connection of
// list widget to stacked widget. Should separate those
// two into free f-ns. Properties dialog should
// implement all of the extra stuff inside it. UI files
// for users of this file will need to be updated to
// contain list/stacked widget.
TabWidget::TabWidget(QWidget *parent)
: QWidget(parent) {
ui = new Ui::TabWidget();
ui->setupUi(this);
auto_switch_tab = true;
ignore_current_row_signal = false;
connect(
ui->list_widget, &QListWidget::currentRowChanged,
this, &TabWidget::on_list_current_row_changed);
}
TabWidget::~TabWidget() {
delete ui;
}
QWidget *TabWidget::get_tab(const int index) const {
QWidget *out = ui->stacked_widget->widget(index);
return out;
}
QWidget *TabWidget::get_current_tab() const {
QWidget *out = ui->stacked_widget->currentWidget();
return out;
}
void TabWidget::set_current_tab(const int index) {
ignore_current_row_signal = true;
ui->list_widget->setCurrentRow(index, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
ignore_current_row_signal = false;
ui->stacked_widget->setCurrentIndex(index);
}
void TabWidget::add_tab(QWidget *tab, const QString &title) {
ui->list_widget->addItem(title);
ui->stacked_widget->addWidget(tab);
}
void TabWidget::enable_auto_switch_tab(const bool enabled) {
auto_switch_tab = enabled;
}
void TabWidget::on_list_current_row_changed(int index) {
if (ignore_current_row_signal) {
return;
}
// NOTE: since tab wasn't change yet in stacked
// widget, we may use it to get previous tab index
const int prev = ui->stacked_widget->currentIndex();
if (auto_switch_tab) {
ui->stacked_widget->setCurrentIndex(index);
} else {
// Restore prev index so current in list widget
// is the same as in stacked widget
ignore_current_row_signal = true;
ui->list_widget->setCurrentRow(prev, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
ignore_current_row_signal = false;
}
emit current_changed(prev, index);
}
| 3,080
|
C++
|
.cpp
| 81
| 34.407407
| 110
| 0.719893
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,593
|
console_filter_dialog.cpp
|
altlinux_admc/src/admc/console_filter_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "console_filter_dialog.h"
#include "ui_console_filter_dialog.h"
#include "adldap.h"
#include "filter_widget/class_filter_widget.h"
#include "filter_widget/filter_dialog.h"
#include "globals.h"
#include "settings.h"
#define FILTER_CUSTOM_DIALOG_STATE "FILTER_CUSTOM_DIALOG_STATE"
#define FILTER_CLASSES_STATE "FILTER_CLASSES_STATE"
ConsoleFilterDialog::ConsoleFilterDialog(QWidget *parent)
: QDialog(parent) {
ui = new Ui::ConsoleFilterDialog();
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
const QList<QString> class_list_for_widget = {
CLASS_USER,
CLASS_GROUP,
CLASS_CONTACT,
CLASS_COMPUTER,
CLASS_PRINTER,
CLASS_SHARED_FOLDER,
};
ui->class_filter_widget->set_classes(class_list_for_widget, class_list_for_widget);
custom_filter = settings_get_variant(SETTING_object_filter).toString();
const int object_display_limit = settings_get_variant(SETTING_object_display_limit).toInt();
ui->limit_spinbox->setValue(object_display_limit);
settings_setup_dialog_geometry(SETTING_console_filter_dialog_geometry, this);
button_state_name_map = {
{"ALL_BUTTON_STATE", ui->all_button},
{"CLASSES_BUTTON_STATE", ui->classes_button},
{"CUSTOM_BUTTON_STATE", ui->custom_button},
};
connect(
ui->custom_dialog_button, &QPushButton::clicked,
this, &ConsoleFilterDialog::open_custom_dialog);
connect(
ui->custom_button, &QAbstractButton::toggled,
this, &ConsoleFilterDialog::on_custom_button);
on_custom_button();
connect(
ui->classes_button, &QAbstractButton::toggled,
this, &ConsoleFilterDialog::on_classes_button);
on_classes_button();
}
bool ConsoleFilterDialog::get_filter_enabled() const {
return !ui->all_button->isChecked();
}
ConsoleFilterDialog::~ConsoleFilterDialog() {
delete ui;
}
void ConsoleFilterDialog::accept() {
const int object_display_limit = ui->limit_spinbox->value();
settings_set_variant(SETTING_object_display_limit, object_display_limit);
QDialog::accept();
}
QVariant ConsoleFilterDialog::save_state() const {
QHash<QString, QVariant> state;
state[FILTER_CUSTOM_DIALOG_STATE] = filter_dialog_state;
state[FILTER_CLASSES_STATE] = ui->class_filter_widget->save_state();
for (const QString &state_name : button_state_name_map.keys()) {
QRadioButton *button = button_state_name_map[state_name];
state[state_name] = button->isChecked();
}
return QVariant(state);
}
void ConsoleFilterDialog::restore_state(const QVariant &state) {
const QHash<QString, QVariant> state_hash = state.toHash();
filter_dialog_state = state_hash[FILTER_CUSTOM_DIALOG_STATE];
ui->class_filter_widget->restore_state(state_hash[FILTER_CLASSES_STATE]);
for (const QString &state_name : button_state_name_map.keys()) {
QRadioButton *button = button_state_name_map[state_name];
const QVariant button_state = state_hash[state_name];
button->setChecked(button_state.toBool());
}
}
QString ConsoleFilterDialog::get_filter() const {
if (ui->all_button->isChecked()) {
return "(objectClass=*)";
} else if (ui->classes_button->isChecked()) {
return ui->class_filter_widget->get_filter();
} else if (ui->custom_button->isChecked()) {
return custom_filter;
}
return QString();
}
void ConsoleFilterDialog::open_custom_dialog() {
// NOTE: Using only non-container classes for filtering
// because container classes need to always be visible
const QList<QString> noncontainer_classes = g_adconfig->get_noncontainer_classes();
auto dialog = new FilterDialog(noncontainer_classes, noncontainer_classes, this);
dialog->restore_state(filter_dialog_state);
dialog->open();
connect(
dialog, &QDialog::accepted,
this,
[this, dialog]() {
filter_dialog_state = dialog->save_state();
custom_filter = dialog->get_filter();
});
}
void ConsoleFilterDialog::on_custom_button() {
const bool checked = ui->custom_button->isChecked();
ui->custom_dialog_button->setEnabled(checked);
}
void ConsoleFilterDialog::on_classes_button() {
const bool checked = ui->classes_button->isChecked();
ui->class_filter_widget->setEnabled(checked);
}
| 5,149
|
C++
|
.cpp
| 127
| 35.669291
| 96
| 0.708066
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,594
|
security_sort_warning_dialog.cpp
|
altlinux_admc/src/admc/security_sort_warning_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "security_sort_warning_dialog.h"
#include "ui_security_sort_warning_dialog.h"
SecuritySortWarningDialog::SecuritySortWarningDialog(QWidget *parent)
: QDialog(parent) {
ui = new Ui::SecuritySortWarningDialog();
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
ui->label->setText(tr("This object's security descriptor contains ACL that has incorrect order. Fix order to proceed with editing. If order is not fixed, Security tab will be read only."));
ui->button_box->addButton(tr("Fix order"), QDialogButtonBox::AcceptRole);
ui->button_box->addButton(tr("Cancel"), QDialogButtonBox::RejectRole);
}
SecuritySortWarningDialog::~SecuritySortWarningDialog() {
delete ui;
}
| 1,490
|
C++
|
.cpp
| 33
| 42.575758
| 193
| 0.759476
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,595
|
main.cpp
|
altlinux_admc/src/admc/main.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "adldap.h"
#include "config.h"
#include "connection_options_dialog.h"
#include "globals.h"
#include "main_window.h"
#include "main_window_connection_error.h"
#include "settings.h"
#include "status.h"
#include "utils.h"
#include "connection_options_dialog.h"
#include "locale.h"
#include "icon_manager/icon_manager.h"
#include <QApplication>
#include <QDebug>
#include <QLibraryInfo>
#include <QTranslator>
int main(int argc, char **argv) {
Q_INIT_RESOURCE(adldap);
// NOTE: this is needed to pass this type from thread's
// signal in find_widget.cpp. Without doing this,
// passing this type from thread results in a runtime
// error.
qRegisterMetaType<QHash<QString, AdObject>>("QHash<QString, AdObject>");
QApplication app(argc, argv);
app.setApplicationDisplayName(ADMC_APPLICATION_DISPLAY_NAME);
app.setApplicationName(ADMC_APPLICATION_NAME);
app.setApplicationVersion(ADMC_VERSION);
app.setOrganizationName(ADMC_ORGANIZATION);
app.setOrganizationDomain(ADMC_ORGANIZATION_DOMAIN);
app.setWindowIcon(QIcon(":/admc/admc.ico"));
const QLocale saved_locale = settings_get_variant(SETTING_locale).toLocale();
const QString locale_dot_UTF8 = saved_locale.name() + ".UTF-8";
const char* locale_for_c = std::setlocale(LC_ALL, locale_dot_UTF8.toLocal8Bit().data());
if (!locale_for_c) {
qDebug() << "Failed to set locale for C libs";
}
QTranslator translator;
const bool loaded_admc_translation = translator.load(saved_locale, "admc", "_", ":/admc");
app.installTranslator(&translator);
if (!loaded_admc_translation) {
qDebug() << "Failed to load admc translation";
}
QTranslator adldap_translator;
const bool loaded_adldap_translation = load_adldap_translation(adldap_translator, saved_locale);
app.installTranslator(&adldap_translator);
if (!loaded_adldap_translation) {
qDebug() << "Failed to load adldap translation";
}
// NOTE: these translations are for qt-defined text, like standard dialog buttons
QTranslator qt_translator;
const bool loaded_qt_translation = qt_translator.load(saved_locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qt_translator);
if (!loaded_qt_translation) {
qDebug() << "Failed to load qt translation";
}
QTranslator qtbase_translator;
const bool loaded_qtbase_translation = qtbase_translator.load(saved_locale, "qtbase", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtbase_translator);
if (!loaded_qtbase_translation) {
qDebug() << "Failed to load qt base translation";
}
load_connection_options();
// In case of failure to connect to AD and load
// adconfig, we open a special alternative main window.
// We do this to acomplish 2 objectives:
// * First, we check that connection is possible at
// startup and give the user an opportunity to
// troubleshoot by adjusting connection options
// (available in the alternative main window).
// * Secondly, we guarantee that the real MainWindow is
// created only after adconfig has been loaded. This
// is needed because many child widgets used by
// MainWindow require adconfig to load their UI
// elements.
//
// Control flow here is awkward for multiple
// reasons. First, the ad error log has to be
// displayed *after* main window is shown and
// parented to it to be modal. Secondly, we need
// adinterface to stay in this scope so that it is
// destroyed when scope is over. If it's created
// outside the scope, then it will stay alive for
// the whole duration of the app which is bad.
QMainWindow *first_main_window = nullptr;
{
AdInterface ad;
if (ad.is_connected()) {
load_g_adconfig(ad);
first_main_window = new MainWindow(ad);
first_main_window->show();
} else {
first_main_window = new MainWindowConnectionError();
first_main_window->show();
ad_error_log(ad, first_main_window);
}
}
const int retval = app.exec();
delete first_main_window;
return retval;
}
| 5,066
|
C++
|
.cpp
| 119
| 37.773109
| 151
| 0.704975
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,596
|
settings.cpp
|
altlinux_admc/src/admc/settings.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "settings.h"
#include "config.h"
#include "connection_options_dialog.h"
#include <QAction>
#include <QDialog>
#include <QHeaderView>
#include <QLocale>
#include <QSettings>
const QHash<QString, QVariant> setting_default_map = {
{SETTING_advanced_features, false},
{SETTING_confirm_actions, true},
{SETTING_show_non_containers_in_console_tree, false},
{SETTING_last_name_before_first_name,
[]() {
const bool locale_is_russian = (QLocale::system().language() == QLocale::Russian);
if (locale_is_russian) {
return true;
} else {
return false;
}
}()},
{SETTING_log_searches, false},
{SETTING_timestamp_log, true},
{SETTING_sasl_nocanon, true},
{SETTING_show_login, true},
{SETTING_host, QString()},
{SETTING_object_filter, QString()},
{SETTING_object_filter_enabled, false},
{SETTING_cert_strategy, CERT_STRATEGY_NEVER_define},
{SETTING_object_display_limit, 1000},
{SETTING_feature_logon_computers, false},
{SETTING_feature_profile_tab, false},
{SETTING_feature_dev_mode, false},
{SETTING_feature_current_locale_first, false},
};
void settings_setup_dialog_geometry(const QString setting, QDialog *dialog) {
settings_restore_geometry(setting, dialog);
QObject::connect(
dialog, &QDialog::finished,
dialog,
[setting, dialog]() {
const QByteArray geometry = dialog->saveGeometry();
settings_set_variant(setting, geometry);
});
}
bool settings_restore_geometry(const QString setting, QWidget *widget) {
const QByteArray geometry = settings_get_variant(setting).toByteArray();
if (!geometry.isEmpty()) {
widget->restoreGeometry(geometry);
return true;
} else {
return false;
}
}
void settings_save_header_state(const QString setting, QHeaderView *header) {
const QByteArray state = header->saveState();
settings_set_variant(setting, state);
}
bool settings_restore_header_state(const QString setting, QHeaderView *header) {
const QByteArray state = settings_get_variant(setting).toByteArray();
if (!state.isEmpty()) {
header->restoreState(state);
return true;
} else {
return false;
}
}
QVariant settings_get_variant(const QString setting) {
QSettings settings;
const QVariant default_value = setting_default_map.value(setting, QVariant());
const QVariant value = settings.value(setting, default_value);
return value;
}
void settings_set_variant(const QString setting, const QVariant &value) {
QSettings settings;
settings.setValue(setting, value);
}
| 3,485
|
C++
|
.cpp
| 96
| 31.385417
| 94
| 0.697123
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,597
|
password_dialog.cpp
|
altlinux_admc/src/admc/password_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "password_dialog.h"
#include "ui_password_dialog.h"
#include "adldap.h"
#include "attribute_edits/account_option_edit.h"
#include "attribute_edits/password_edit.h"
#include "attribute_edits/unlock_edit.h"
#include "globals.h"
#include "settings.h"
#include "status.h"
#include "utils.h"
#include <QPushButton>
PasswordDialog::PasswordDialog(AdInterface &ad, const QString &target_arg, QWidget *parent)
: QDialog(parent) {
ui = new Ui::PasswordDialog();
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
auto password_main_edit = new PasswordEdit(ui->password_main_edit, ui->password_confirm_edit, ui->show_password_check, this);
pass_expired_edit = new AccountOptionEdit(ui->expired_check, AccountOption_PasswordExpired, this);
auto unlock_edit = new UnlockEdit(ui->unlock_check, this);
target = target_arg;
edits = {
password_main_edit,
pass_expired_edit,
unlock_edit,
};
const AdObject object = ad.search_object(target);
AttributeEdit::load(edits, ad, object);
const bool expired_check_enabled = [&]() {
const bool dont_expire_pass = object.get_account_option(AccountOption_DontExpirePassword, g_adconfig);
const bool cant_change_pass = object.get_account_option(AccountOption_CantChangePassword, g_adconfig);
const bool out = !(dont_expire_pass || cant_change_pass);
return out;
}();
if (expired_check_enabled) {
ui->expired_check->setChecked(true);
} else {
ui->expired_check->setEnabled(false);
ui->expired_check->setToolTip(tr("Option is unavailable because a conflicting account option is currently enabled."));
}
required_list = {
ui->password_main_edit,
ui->password_confirm_edit,
};
for (QLineEdit *edit : required_list) {
connect(
edit, &QLineEdit::textChanged,
this, &PasswordDialog::on_edited);
}
on_edited();
settings_setup_dialog_geometry(SETTING_password_dialog_geometry, this);
}
PasswordDialog::~PasswordDialog() {
delete ui;
}
void PasswordDialog::accept() {
AdInterface ad;
if (ad_failed(ad, this)) {
return;
}
show_busy_indicator();
const bool verify_success = AttributeEdit::verify(edits, ad, target);
if (!verify_success) {
return;
}
const bool apply_success = AttributeEdit::apply(edits, ad, target);
hide_busy_indicator();
g_status->display_ad_messages(ad, this);
if (apply_success) {
QDialog::accept();
}
}
void PasswordDialog::on_edited() {
const bool all_required_filled = [this]() {
for (QLineEdit *edit : required_list) {
if (edit->text().isEmpty()) {
return false;
}
}
return true;
}();
auto ok_button = ui->button_box->button(QDialogButtonBox::Ok);
ok_button->setEnabled(all_required_filled);
}
| 3,716
|
C++
|
.cpp
| 102
| 31.323529
| 129
| 0.685635
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,538,598
|
changelog_dialog.cpp
|
altlinux_admc/src/admc/changelog_dialog.cpp
|
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020-2022 BaseALT Ltd.
* Copyright (C) 2020-2022 Dmitry Degtyarev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "changelog_dialog.h"
#include "ui_changelog_dialog.h"
#include "config.h"
#include "settings.h"
#include <QCoreApplication>
#include <QDebug>
#include <QStandardPaths>
ChangelogDialog::ChangelogDialog(QWidget *parent)
: QDialog(parent) {
ui = new Ui::ChangelogDialog();
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
const QString changelog_text = []() {
const QString fail_text = tr("Failed to open changelog file.");
const QString changelog_path = []() {
const QString changelog_file_name = [&]() {
const QLocale saved_locale = settings_get_variant(SETTING_locale).toLocale();
if (saved_locale.language() == QLocale::Russian) {
return "CHANGELOG_ru.txt";
} else {
return "CHANGELOG.txt";
}
}();
#ifdef QT_DEBUG
return QString("%1/%2").arg(QCoreApplication::applicationDirPath(), changelog_file_name);
#endif
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("doc/admc-%1/%2").arg(ADMC_VERSION, changelog_file_name));
}();
if (changelog_path.isEmpty()) {
return fail_text;
}
QFile file(changelog_path);
const bool open_success = file.open(QIODevice::ReadOnly);
if (!open_success) {
qDebug() << "Failed to open changelog file";
return fail_text;
}
QString out = file.readAll();
file.close();
// Remove forced word wrap contained in
// CHANGELOG.txt so that resizing the dialog
// expands text width (all wrapped lines start
// with 2 spaces)
out.replace("\n ", " ");
return out;
}();
ui->edit->setPlainText(changelog_text);
settings_setup_dialog_geometry(SETTING_changelog_dialog_geometry, this);
}
ChangelogDialog::~ChangelogDialog() {
delete ui;
}
| 2,744
|
C++
|
.cpp
| 71
| 32.084507
| 145
| 0.654223
|
altlinux/admc
| 36
| 14
| 14
|
GPL-3.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.